ranjith-dev #325
@@ -5,155 +5,152 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\AlertMailRuleExporter;
|
use App\Filament\Exports\AlertMailRuleExporter;
|
||||||
use App\Filament\Imports\AlertMailRuleImporter;
|
use App\Filament\Imports\AlertMailRuleImporter;
|
||||||
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||||
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
|
|
||||||
use App\Models\AlertMailRule;
|
use App\Models\AlertMailRule;
|
||||||
use App\Models\InvoiceMaster;
|
use App\Models\InvoiceMaster;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Dotenv\Exception\ValidationException;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Components\Checkbox;
|
use Filament\Forms\Components\Checkbox;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Validation\ValidationException as ValidationValidationException;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class AlertMailRuleResource extends Resource
|
class AlertMailRuleResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = AlertMailRule::class;
|
protected static ?string $model = AlertMailRule::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-m-bell-alert';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Alert Mail';
|
protected static ?string $navigationGroup = 'Alert Mail';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
|
||||||
Section::make('')
|
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant')
|
Section::make('')
|
||||||
->label('Plant')
|
->schema([
|
||||||
->reactive()
|
Forms\Components\Select::make('plant')
|
||||||
->options(function (callable $get) {
|
->label('Plant')
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
->reactive()
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
->options(function (callable $get) {
|
||||||
})
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
->required(fn ($get) => ! $get('is_active'))
|
|
||||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
})
|
||||||
Forms\Components\Select::make('module')
|
->required(fn ($get) => ! $get('is_active'))
|
||||||
->label('Module')
|
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||||
->required()
|
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
||||||
->options([
|
Forms\Components\Select::make('module')
|
||||||
'InvoiceValidation' => 'InvoiceValidation',
|
->label('Module')
|
||||||
'InvoiceDataReport' => 'InvoiceDataReport',
|
->required()
|
||||||
'ProductionQuantities' => 'ProductionQuantities',
|
->options([
|
||||||
'QualityValidation' => 'QualityValidation',
|
'InvoiceValidation' => 'InvoiceValidation',
|
||||||
'InvoiceTransit' => 'InvoiceTransit',
|
'InvoiceDataReport' => 'InvoiceDataReport',
|
||||||
]),
|
'ProductionQuantities' => 'ProductionQuantities',
|
||||||
Forms\Components\Select::make('rule_name')
|
'QualityValidation' => 'QualityValidation',
|
||||||
->label('Rule Name')
|
'InvoiceTransit' => 'InvoiceTransit',
|
||||||
->options([
|
]),
|
||||||
'InvoiceMail' => 'Invoice Mail',
|
Forms\Components\Select::make('rule_name')
|
||||||
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
->label('Rule Name')
|
||||||
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
->options([
|
||||||
'ProductionMail' => 'Production Mail',
|
'InvoiceMail' => 'Invoice Mail',
|
||||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
||||||
'QualityMail' => 'Quality Mail',
|
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
||||||
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
'ProductionMail' => 'Production Mail',
|
||||||
|
'InvoiceDataMail' => 'Invoice Data Mail',
|
||||||
|
'QualityMail' => 'Quality Mail',
|
||||||
|
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
||||||
|
])
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('email')
|
||||||
|
->label('Email')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Textarea::make('cc_emails')
|
||||||
|
->label('CC Emails'),
|
||||||
|
Forms\Components\Select::make('schedule_type')
|
||||||
|
->label('Schedule Type')
|
||||||
|
->options([
|
||||||
|
'Live' => 'Live',
|
||||||
|
'Hourly' => 'Hourly',
|
||||||
|
'Daily' => 'Daily',
|
||||||
|
]),
|
||||||
|
Forms\Components\Select::make('receiving_plant_name')
|
||||||
|
->label('Receiving Plant')
|
||||||
|
->options(
|
||||||
|
InvoiceMaster::query()
|
||||||
|
->whereNotNull('receiving_plant_name')
|
||||||
|
->select('receiving_plant_name')
|
||||||
|
->distinct()
|
||||||
|
->pluck('receiving_plant_name', 'receiving_plant_name')
|
||||||
|
)
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('invoice_master_id', null);
|
||||||
|
}),
|
||||||
|
Forms\Components\Select::make('invoice_master_id')
|
||||||
|
->label('Transporter Name')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$recPlant = $get('receiving_plant_name');
|
||||||
|
|
||||||
|
if (! $recPlant) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return InvoiceMaster::query()
|
||||||
|
->where('receiving_plant_name', $recPlant)
|
||||||
|
->whereNotNull('transport_name')
|
||||||
|
->where('transport_name', '!=', '')
|
||||||
|
->orderBy('transport_name')
|
||||||
|
->pluck('transport_name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->searchable(),
|
||||||
|
Checkbox::make('is_active')
|
||||||
|
->label('All Plants Reports')
|
||||||
|
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
|
||||||
|
->reactive(),
|
||||||
|
// Forms\Components\Actions::make([
|
||||||
|
// Action::make('sendInvoiceData')
|
||||||
|
// ->label('Invoice Data Report')
|
||||||
|
// ->action(function ($get) {
|
||||||
|
|
||||||
|
// $plantIds = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||||
|
// ->orderBy('plant')
|
||||||
|
// ->pluck('plant')
|
||||||
|
// ->toArray();
|
||||||
|
|
||||||
|
// foreach ($plantIds as $plantId) {
|
||||||
|
// Artisan::call('send:invoice-data-report', [
|
||||||
|
// 'schedule_type' => 'Daily',
|
||||||
|
// 'plant' => $plantId,
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Notify user in Filament
|
||||||
|
// Notification::make()
|
||||||
|
// ->title('Invoice data report sent successfully!')
|
||||||
|
// ->success()
|
||||||
|
// ->send();
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// ]),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->default(fn () => Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->default(fn () => Filament::auth()->user()?->name),
|
||||||
])
|
])
|
||||||
->required(),
|
->columns(2),
|
||||||
Forms\Components\TextInput::make('email')
|
]);
|
||||||
->label('Email')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Textarea::make('cc_emails')
|
|
||||||
->label('CC Emails'),
|
|
||||||
Forms\Components\Select::make('schedule_type')
|
|
||||||
->label('Schedule Type')
|
|
||||||
->options([
|
|
||||||
'Live' => 'Live',
|
|
||||||
'Hourly' => 'Hourly',
|
|
||||||
'Daily' => 'Daily',
|
|
||||||
]),
|
|
||||||
Forms\Components\Select::make('receiving_plant_name')
|
|
||||||
->label('Receiving Plant')
|
|
||||||
->options(
|
|
||||||
InvoiceMaster::query()
|
|
||||||
->whereNotNull('receiving_plant_name')
|
|
||||||
->select('receiving_plant_name')
|
|
||||||
->distinct()
|
|
||||||
->pluck('receiving_plant_name', 'receiving_plant_name')
|
|
||||||
)
|
|
||||||
->searchable()
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('invoice_master_id', null);
|
|
||||||
}),
|
|
||||||
Forms\Components\Select::make('invoice_master_id')
|
|
||||||
->label('Transporter Name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$recPlant = $get('receiving_plant_name');
|
|
||||||
|
|
||||||
if (! $recPlant) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return InvoiceMaster::query()
|
|
||||||
->where('receiving_plant_name', $recPlant)
|
|
||||||
->whereNotNull('transport_name')
|
|
||||||
->where('transport_name', '!=', '')
|
|
||||||
->orderBy('transport_name')
|
|
||||||
->pluck('transport_name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->searchable(),
|
|
||||||
Checkbox::make('is_active')
|
|
||||||
->label('All Plants Reports')
|
|
||||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
|
|
||||||
->reactive(),
|
|
||||||
// Forms\Components\Actions::make([
|
|
||||||
// Action::make('sendInvoiceData')
|
|
||||||
// ->label('Invoice Data Report')
|
|
||||||
// ->action(function ($get) {
|
|
||||||
|
|
||||||
// $plantIds = AlertMailRule::where('module', 'InvoiceDataReport')
|
|
||||||
// ->orderBy('plant')
|
|
||||||
// ->pluck('plant')
|
|
||||||
// ->toArray();
|
|
||||||
|
|
||||||
// foreach ($plantIds as $plantId) {
|
|
||||||
// Artisan::call('send:invoice-data-report', [
|
|
||||||
// 'schedule_type' => 'Daily',
|
|
||||||
// 'plant' => $plantId,
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Notify user in Filament
|
|
||||||
// Notification::make()
|
|
||||||
// ->title('Invoice data report sent successfully!')
|
|
||||||
// ->success()
|
|
||||||
// ->send();
|
|
||||||
// }),
|
|
||||||
|
|
||||||
// ]),
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
|
||||||
->default(fn () => Filament::auth()->user()?->name),
|
|
||||||
Forms\Components\Hidden::make('updated_by')
|
|
||||||
->default(fn () => Filament::auth()->user()?->name),
|
|
||||||
])
|
|
||||||
->columns(2),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
@@ -166,6 +163,7 @@ class AlertMailRuleResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant')
|
Tables\Columns\TextColumn::make('plant')
|
||||||
@@ -178,6 +176,7 @@ class AlertMailRuleResource extends Resource
|
|||||||
if (! $plants) {
|
if (! $plants) {
|
||||||
$plants = Plant::pluck('name', 'id')->toArray();
|
$plants = Plant::pluck('name', 'id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $plants[$state] ?? 'All Plants';
|
return $plants[$state] ?? 'All Plants';
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('module')
|
Tables\Columns\TextColumn::make('module')
|
||||||
@@ -260,14 +259,14 @@ class AlertMailRuleResource extends Resource
|
|||||||
->label('Import Alert Mail Rule')
|
->label('Import Alert Mail Rule')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(AlertMailRuleImporter::class)
|
->importer(AlertMailRuleImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import alert mail rule');
|
return Filament::auth()->user()->can('view import alert mail rule');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Alert Mail Rule')
|
->label('Export Alert Mail Rule')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(AlertMailRuleExporter::class)
|
->exporter(AlertMailRuleExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export alert mail rule');
|
return Filament::auth()->user()->can('view export alert mail rule');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ use App\Models\Block;
|
|||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class BlockResource extends Resource
|
class BlockResource extends Resource
|
||||||
@@ -46,12 +46,11 @@ class BlockResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$nameId = $get('name');
|
$nameId = $get('name');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
if (!$nameId) {
|
if (! $nameId) {
|
||||||
$set('bNameError', 'Scan the valid name.');
|
$set('bNameError', 'Scan the valid name.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('bNameError', null);
|
$set('bNameError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -72,21 +71,21 @@ class BlockResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Block::latest()->first())->plant_id;
|
return optional(Block::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$nameId = $get('plant_id');
|
$nameId = $get('plant_id');
|
||||||
// Ensure `linestop_id` is not cleared
|
// Ensure `linestop_id` is not cleared
|
||||||
if (!$nameId) {
|
if (! $nameId) {
|
||||||
$set('bPlantError', 'Please select a plant first.');
|
$set('bPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('bPlantError', null);
|
$set('bPlantError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -98,7 +97,7 @@ class BlockResource extends Resource
|
|||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -117,10 +116,11 @@ class BlockResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
//->unique(ignoreRecord: true)
|
// ->unique(ignoreRecord: true)
|
||||||
->label('Block')
|
->label('Block')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
@@ -167,14 +167,14 @@ class BlockResource extends Resource
|
|||||||
->label('Import Blocks')
|
->label('Import Blocks')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(BlockImporter::class)
|
->importer(BlockImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import block');
|
return Filament::auth()->user()->can('view import block');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Blocks')
|
->label('Export Blocks')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(BlockExporter::class)
|
->exporter(BlockExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export block');
|
return Filament::auth()->user()->can('view export block');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
@@ -296,7 +296,7 @@ class CharacteristicValueResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\CheckPointNameExporter;
|
use App\Filament\Exports\CheckPointNameExporter;
|
||||||
use App\Filament\Imports\CheckPointNameImporter;
|
use App\Filament\Imports\CheckPointNameImporter;
|
||||||
use App\Filament\Resources\CheckPointNameResource\Pages;
|
use App\Filament\Resources\CheckPointNameResource\Pages;
|
||||||
use App\Filament\Resources\CheckPointNameResource\RelationManagers;
|
|
||||||
use App\Models\CheckPointName;
|
use App\Models\CheckPointName;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -42,20 +41,20 @@ class CheckPointNameResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('cPnPlantError', 'Please select a plant first.');
|
$set('cPnPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cPnPlantError', null);
|
$set('cPnPlantError', null);
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
}
|
}
|
||||||
@@ -100,6 +99,7 @@ class CheckPointNameResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
// Tables\Columns\TextColumn::make('id')
|
// Tables\Columns\TextColumn::make('id')
|
||||||
@@ -156,14 +156,14 @@ class CheckPointNameResource extends Resource
|
|||||||
->label('Import Check Point Names')
|
->label('Import Check Point Names')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(CheckPointNameImporter::class)
|
->importer(CheckPointNameImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import check point name');
|
return Filament::auth()->user()->can('view import check point name');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Check Point Names')
|
->label('Export Check Point Names')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(CheckPointNameExporter::class)
|
->exporter(CheckPointNameExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export check point name');
|
return Filament::auth()->user()->can('view export check point name');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\CheckPointTimeExporter;
|
use App\Filament\Exports\CheckPointTimeExporter;
|
||||||
use App\Filament\Imports\CheckPointTimeImporter;
|
use App\Filament\Imports\CheckPointTimeImporter;
|
||||||
use App\Filament\Resources\CheckPointTimeResource\Pages;
|
use App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||||
use App\Filament\Resources\CheckPointTimeResource\RelationManagers;
|
|
||||||
use App\Models\CheckPointName;
|
use App\Models\CheckPointName;
|
||||||
use App\Models\CheckPointTime;
|
use App\Models\CheckPointTime;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
@@ -43,20 +42,20 @@ class CheckPointTimeResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('cPtPlantError', 'Please select a plant first.');
|
$set('cPtPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cPtPlantError', null);
|
$set('cPtPlantError', null);
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
}
|
}
|
||||||
@@ -78,17 +77,17 @@ class CheckPointTimeResource extends Resource
|
|||||||
})
|
})
|
||||||
->rule(function (callable $get) {
|
->rule(function (callable $get) {
|
||||||
return Rule::unique('check_point_times', 'sequence_number')
|
return Rule::unique('check_point_times', 'sequence_number')
|
||||||
->where('plant_id', $get('plant_id'))
|
->where('plant_id', $get('plant_id'))
|
||||||
->ignore($get('id'));
|
->ignore($get('id'));
|
||||||
//->where('check_point1_id', $get('check_point1_id'))
|
// ->where('check_point1_id', $get('check_point1_id'))
|
||||||
//->where('check_point2_id', $get('check_point2_id'))
|
// ->where('check_point2_id', $get('check_point2_id'))
|
||||||
}),
|
}),
|
||||||
Forms\Components\Select::make('check_point1_id')
|
Forms\Components\Select::make('check_point1_id')
|
||||||
->label('Check Point Name 1')
|
->label('Check Point Name 1')
|
||||||
// ->relationship('checkPointNames', 'name')
|
// ->relationship('checkPointNames', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,19 +100,19 @@ class CheckPointTimeResource extends Resource
|
|||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point1_id;
|
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point1_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$checkPoint1 = $get('check_point1_id');
|
$checkPoint1 = $get('check_point1_id');
|
||||||
$checkPoint2 = $get('check_point2_id');
|
$checkPoint2 = $get('check_point2_id');
|
||||||
if (!$checkPoint1) {
|
if (! $checkPoint1) {
|
||||||
$set('cPtCheckPoint1Error', 'Please select a check point 1 first.');
|
$set('cPtCheckPoint1Error', 'Please select a check point 1 first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($checkPoint2 && $checkPoint1 == $checkPoint2) {
|
if ($checkPoint2 && $checkPoint1 == $checkPoint2) {
|
||||||
$set('cPtCheckPoint1Error', 'Duplicate check point 2 found.');
|
$set('cPtCheckPoint1Error', 'Duplicate check point 2 found.');
|
||||||
$set('check_point2_id', null);
|
$set('check_point2_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$set('cPtCheckPoint1Error', null);
|
$set('cPtCheckPoint1Error', null);
|
||||||
@@ -131,7 +130,7 @@ class CheckPointTimeResource extends Resource
|
|||||||
// ->relationship('checkPointNames', 'name')
|
// ->relationship('checkPointNames', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,19 +143,19 @@ class CheckPointTimeResource extends Resource
|
|||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point2_id;
|
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point2_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$checkPoint1 = $get('check_point1_id');
|
$checkPoint1 = $get('check_point1_id');
|
||||||
$checkPoint2 = $get('check_point2_id');
|
$checkPoint2 = $get('check_point2_id');
|
||||||
if (!$checkPoint2) {
|
if (! $checkPoint2) {
|
||||||
$set('cPtCheckPoint2Error', 'Please select a check point 2 first.');
|
$set('cPtCheckPoint2Error', 'Please select a check point 2 first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($checkPoint1 && $checkPoint1 == $checkPoint2) {
|
if ($checkPoint1 && $checkPoint1 == $checkPoint2) {
|
||||||
$set('cPtCheckPoint2Error', 'Duplicate check point 2 found.');
|
$set('cPtCheckPoint2Error', 'Duplicate check point 2 found.');
|
||||||
$set('check_point2_id', null);
|
$set('check_point2_id', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$set('cPtCheckPoint1Error', null);
|
$set('cPtCheckPoint1Error', null);
|
||||||
@@ -185,32 +184,30 @@ class CheckPointTimeResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$timeLapse = $state;
|
$timeLapse = $state;
|
||||||
$timeLapseCushioning = $get('time_lapse_cushioning');
|
$timeLapseCushioning = $get('time_lapse_cushioning');
|
||||||
if (!$timeLapse) {
|
if (! $timeLapse) {
|
||||||
$set('cPtTimeLapseError', 'Please enter a valid time lapse!');
|
$set('cPtTimeLapseError', 'Please enter a valid time lapse!');
|
||||||
$set('time_lapse_cushioning', null);
|
$set('time_lapse_cushioning', null);
|
||||||
$set('min_cushioning', null);
|
$set('min_cushioning', null);
|
||||||
$set('max_cushioning', null);
|
$set('max_cushioning', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! $timeLapseCushioning) {
|
||||||
elseif(!$timeLapseCushioning)
|
|
||||||
{
|
|
||||||
// $set('cPtTimeLapseError', 'Please enter a valid time lapse cushioning!');
|
// $set('cPtTimeLapseError', 'Please enter a valid time lapse cushioning!');
|
||||||
$set('time_lapse_cushioning', 1);
|
$set('time_lapse_cushioning', 1);
|
||||||
$set('cPtTimeLapseError', null);
|
$set('cPtTimeLapseError', null);
|
||||||
$set('min_cushioning', $timeLapse - 1);
|
$set('min_cushioning', $timeLapse - 1);
|
||||||
$set('max_cushioning', $timeLapse + 1);
|
$set('max_cushioning', $timeLapse + 1);
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif ($timeLapseCushioning > $timeLapse) {
|
||||||
elseif ($timeLapseCushioning > $timeLapse) {
|
|
||||||
$set('cPtTimeLapseError', 'Must be greater than or equal to time lapse cushioning!');
|
$set('cPtTimeLapseError', 'Must be greater than or equal to time lapse cushioning!');
|
||||||
$set('time_lapse_cushioning', null);
|
$set('time_lapse_cushioning', null);
|
||||||
$set('min_cushioning', null);
|
$set('min_cushioning', null);
|
||||||
$set('max_cushioning', null);
|
$set('max_cushioning', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cPtTimeLapseError', null);
|
$set('cPtTimeLapseError', null);
|
||||||
$set('cPtTimeLapseCushError', null);
|
$set('cPtTimeLapseCushError', null);
|
||||||
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
||||||
@@ -233,32 +230,30 @@ class CheckPointTimeResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$timeLapse = $get('time_lapse');
|
$timeLapse = $get('time_lapse');
|
||||||
$timeLapseCushioning = $state;
|
$timeLapseCushioning = $state;
|
||||||
if (!$timeLapse) {
|
if (! $timeLapse) {
|
||||||
$set('cPtTimeLapseCushError', 'Please enter a valid time lapse first.');
|
$set('cPtTimeLapseCushError', 'Please enter a valid time lapse first.');
|
||||||
$set('time_lapse_cushioning', null);
|
$set('time_lapse_cushioning', null);
|
||||||
$set('min_cushioning', null);
|
$set('min_cushioning', null);
|
||||||
$set('max_cushioning', null);
|
$set('max_cushioning', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! $timeLapseCushioning) {
|
||||||
elseif(!$timeLapseCushioning)
|
|
||||||
{
|
|
||||||
// $set('cPtTimeLapseCushError', 'Please enter a valid time lapse cushioning!');
|
// $set('cPtTimeLapseCushError', 'Please enter a valid time lapse cushioning!');
|
||||||
$set('time_lapse_cushioning', 1);
|
$set('time_lapse_cushioning', 1);
|
||||||
$set('cPtTimeLapseCushError', null);
|
$set('cPtTimeLapseCushError', null);
|
||||||
$set('min_cushioning', $timeLapse - 1);
|
$set('min_cushioning', $timeLapse - 1);
|
||||||
$set('max_cushioning', $timeLapse + 1);
|
$set('max_cushioning', $timeLapse + 1);
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif ($timeLapseCushioning > $timeLapse) {
|
||||||
elseif ($timeLapseCushioning > $timeLapse) {
|
|
||||||
$set('cPtTimeLapseCushError', 'Must be less than or equal to time lapse!');
|
$set('cPtTimeLapseCushError', 'Must be less than or equal to time lapse!');
|
||||||
$set('time_lapse_cushioning', null);
|
$set('time_lapse_cushioning', null);
|
||||||
$set('min_cushioning', null);
|
$set('min_cushioning', null);
|
||||||
$set('max_cushioning', null);
|
$set('max_cushioning', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cPtTimeLapseError', null);
|
$set('cPtTimeLapseError', null);
|
||||||
$set('cPtTimeLapseCushError', null);
|
$set('cPtTimeLapseCushError', null);
|
||||||
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
||||||
@@ -308,6 +303,7 @@ class CheckPointTimeResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
// Tables\Columns\TextColumn::make('id')
|
// Tables\Columns\TextColumn::make('id')
|
||||||
@@ -387,14 +383,14 @@ class CheckPointTimeResource extends Resource
|
|||||||
->label('Import Check Point Times')
|
->label('Import Check Point Times')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(CheckPointTimeImporter::class)
|
->importer(CheckPointTimeImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import check point time');
|
return Filament::auth()->user()->can('view import check point time');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Check Point Times')
|
->label('Export Check Point Times')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(CheckPointTimeExporter::class)
|
->exporter(CheckPointTimeExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export check point time');
|
return Filament::auth()->user()->can('view export check point time');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ClassCharacteristicResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\ConfigurationExporter;
|
use App\Filament\Exports\ConfigurationExporter;
|
||||||
use App\Filament\Imports\ConfigurationImporter;
|
use App\Filament\Imports\ConfigurationImporter;
|
||||||
use App\Filament\Resources\ConfigurationResource\Pages;
|
use App\Filament\Resources\ConfigurationResource\Pages;
|
||||||
use App\Filament\Resources\ConfigurationResource\RelationManagers;
|
|
||||||
use App\Models\Configuration;
|
use App\Models\Configuration;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
@@ -15,18 +14,20 @@ use Filament\Forms\Form;
|
|||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class ConfigurationResource extends Resource
|
class ConfigurationResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = Configuration::class;
|
protected static ?string $model = Configuration::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
protected static ?string $navigationGroup = 'Master Entries';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 10;
|
protected static ?int $navigationSort = 10;
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
@@ -40,20 +41,20 @@ class ConfigurationResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Configuration::latest()->first())->plant_id;
|
return optional(Configuration::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('cPlantError', 'Please select a plant first.');
|
$set('cPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cPlantError', null);
|
$set('cPlantError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -68,7 +69,7 @@ class ConfigurationResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (!$get('plant_id')) {
|
if (! $get('plant_id')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,15 +80,14 @@ class ConfigurationResource extends Resource
|
|||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Configuration::latest()->first())->line_id;
|
return optional(Configuration::latest()->first())->line_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$lineId = $get('line_id');
|
$lineId = $get('line_id');
|
||||||
if (!$lineId) {
|
if (! $lineId) {
|
||||||
$set('cLineError', 'Please select a line first.');
|
$set('cLineError', 'Please select a line first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('cLineError', null);
|
$set('cLineError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -124,6 +124,7 @@ class ConfigurationResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -186,14 +187,14 @@ class ConfigurationResource extends Resource
|
|||||||
->label('Import Configurations')
|
->label('Import Configurations')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(ConfigurationImporter::class)
|
->importer(ConfigurationImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import configuration');
|
return Filament::auth()->user()->can('view import configuration');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Configurations')
|
->label('Export Configurations')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(ConfigurationExporter::class)
|
->exporter(ConfigurationExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export configuration');
|
return Filament::auth()->user()->can('view export configuration');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -5,53 +5,54 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\DeviceMasterExporter;
|
use App\Filament\Exports\DeviceMasterExporter;
|
||||||
use App\Filament\Imports\DeviceMasterImporter;
|
use App\Filament\Imports\DeviceMasterImporter;
|
||||||
use App\Filament\Resources\DeviceMasterResource\Pages;
|
use App\Filament\Resources\DeviceMasterResource\Pages;
|
||||||
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
|
|
||||||
use App\Models\DeviceMaster;
|
use App\Models\DeviceMaster;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class DeviceMasterResource extends Resource
|
class DeviceMasterResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = DeviceMaster::class;
|
protected static ?string $model = DeviceMaster::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
protected static ?string $navigationGroup = 'Power House';
|
|
||||||
|
protected static ?string $navigationGroup = 'Power House';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
->required(),
|
})
|
||||||
Forms\Components\TextInput::make('name')
|
->required(),
|
||||||
->label('Device Name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required(),
|
->label('Device Name')
|
||||||
Forms\Components\TextInput::make('mac_address')
|
->required(),
|
||||||
->label('MAC Address'),
|
Forms\Components\TextInput::make('mac_address')
|
||||||
Forms\Components\TextInput::make('ip_address')
|
->label('MAC Address'),
|
||||||
->label('IP Address'),
|
Forms\Components\TextInput::make('ip_address')
|
||||||
Forms\Components\Hidden::make('created_by')
|
->label('IP Address'),
|
||||||
->default(Filament::auth()->user()?->name),
|
Forms\Components\Hidden::make('created_by')
|
||||||
])
|
->default(Filament::auth()->user()?->name),
|
||||||
->columns(4),
|
])
|
||||||
|
->columns(4),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ class DeviceMasterResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -120,14 +122,14 @@ class DeviceMasterResource extends Resource
|
|||||||
->label('Import Device Masters')
|
->label('Import Device Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(DeviceMasterImporter::class)
|
->importer(DeviceMasterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import device master');
|
return Filament::auth()->user()->can('view import device master');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Device Masters')
|
->label('Export Device Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(DeviceMasterExporter::class)
|
->exporter(DeviceMasterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export device master');
|
return Filament::auth()->user()->can('view export device master');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class EbReadingResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('lcd_segment_check')
|
Forms\Components\TextInput::make('lcd_segment_check')
|
||||||
@@ -336,7 +336,7 @@ class EbReadingResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -5,25 +5,24 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\EquipmentMasterExporter;
|
use App\Filament\Exports\EquipmentMasterExporter;
|
||||||
use App\Filament\Imports\EquipmentMasterImporter;
|
use App\Filament\Imports\EquipmentMasterImporter;
|
||||||
use App\Filament\Resources\EquipmentMasterResource\Pages;
|
use App\Filament\Resources\EquipmentMasterResource\Pages;
|
||||||
use App\Filament\Resources\EquipmentMasterResource\RelationManagers;
|
|
||||||
use App\Models\EquipmentMaster;
|
use App\Models\EquipmentMaster;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Facades\Filament;
|
use Illuminate\Validation\Rule;
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
use Storage;
|
use Storage;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
|
|
||||||
class EquipmentMasterResource extends Resource
|
class EquipmentMasterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -45,11 +44,12 @@ class EquipmentMasterResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('machine_id')
|
Forms\Components\Select::make('machine_id')
|
||||||
//->relationship('machine', 'name')
|
// ->relationship('machine', 'name')
|
||||||
->label('Work Center')
|
->label('Work Center')
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -57,6 +57,7 @@ class EquipmentMasterResource extends Resource
|
|||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
@@ -93,19 +94,19 @@ class EquipmentMasterResource extends Resource
|
|||||||
$set('attachment', null);
|
$set('attachment', null);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
//->afterStateUpdated(function ($state, callable $set) {
|
// ->afterStateUpdated(function ($state, callable $set) {
|
||||||
// if (! $state) {
|
// if (! $state) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $model = EquipmentMaster::where('equipment_number', $state)->first();
|
// $model = EquipmentMaster::where('equipment_number', $state)->first();
|
||||||
|
|
||||||
// if ($model?->attachment) {
|
// if ($model?->attachment) {
|
||||||
// $set('attachment', $model->attachment);
|
// $set('attachment', $model->attachment);
|
||||||
// } else {
|
// } else {
|
||||||
// $set('attachment', null);
|
// $set('attachment', null);
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
Forms\Components\TextInput::make('instrument_serial_number')
|
Forms\Components\TextInput::make('instrument_serial_number')
|
||||||
->label('Instrument Serial Number'),
|
->label('Instrument Serial Number'),
|
||||||
// Forms\Components\DateTimePicker::make('calibrated_on')
|
// Forms\Components\DateTimePicker::make('calibrated_on')
|
||||||
@@ -128,17 +129,17 @@ class EquipmentMasterResource extends Resource
|
|||||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
||||||
$set('next_calibration_date', $nextDate);
|
$set('next_calibration_date', $nextDate);
|
||||||
}),
|
}),
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
// $frequency = (int) $get('frequency');
|
// $frequency = (int) $get('frequency');
|
||||||
|
|
||||||
// if ($state && $frequency != 0) {
|
// if ($state && $frequency != 0) {
|
||||||
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
|
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
|
||||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
||||||
// $set('next_calibration_date', $nextDate);
|
// $set('next_calibration_date', $nextDate);
|
||||||
// } else {
|
// } else {
|
||||||
// $set('next_calibration_date', null);
|
// $set('next_calibration_date', null);
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('frequency')
|
Forms\Components\TextInput::make('frequency')
|
||||||
->label('Frequency (days)')
|
->label('Frequency (days)')
|
||||||
@@ -152,20 +153,20 @@ class EquipmentMasterResource extends Resource
|
|||||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
||||||
$set('next_calibration_date', $nextDate);
|
$set('next_calibration_date', $nextDate);
|
||||||
}),
|
}),
|
||||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
// $calibratedOn = $get('calibrated_on');
|
// $calibratedOn = $get('calibrated_on');
|
||||||
// $frequency = (int) $state;
|
// $frequency = (int) $state;
|
||||||
|
|
||||||
// if ($calibratedOn && $frequency !== 0) {
|
// if ($calibratedOn && $frequency !== 0) {
|
||||||
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
|
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
|
||||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
||||||
// $set('next_calibration_date', $nextDate);
|
// $set('next_calibration_date', $nextDate);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// $set('next_calibration_date', null);
|
// $set('next_calibration_date', null);
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
|
|
||||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||||
->label('Next Calibration Date')
|
->label('Next Calibration Date')
|
||||||
@@ -266,7 +267,7 @@ class EquipmentMasterResource extends Resource
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
->action(function ($get, callable $set) {
|
->action(function ($get, callable $set) {
|
||||||
$uploadedFiles = $get('attachment');
|
$uploadedFiles = $get('attachment');
|
||||||
|
|
||||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||||
@@ -285,16 +286,16 @@ class EquipmentMasterResource extends Resource
|
|||||||
->title('PDF uploaded successfully')
|
->title('PDF uploaded successfully')
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
return;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No file selected to upload')
|
->title('No file selected to upload')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
return;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -303,11 +304,12 @@ class EquipmentMasterResource extends Resource
|
|||||||
->action(function ($get) {
|
->action(function ($get) {
|
||||||
$equipmentNumber = $get('equipment_number');
|
$equipmentNumber = $get('equipment_number');
|
||||||
|
|
||||||
if (!$equipmentNumber) {
|
if (! $equipmentNumber) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No equipment number entered')
|
->title('No equipment number entered')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,18 +323,19 @@ class EquipmentMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$fileToDownload) {
|
if (! $fileToDownload) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('PDF not found for this equipment')
|
->title('PDF not found for this equipment')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
@@ -342,17 +345,17 @@ class EquipmentMasterResource extends Resource
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('No.')
|
Tables\Columns\TextColumn::make('No.')
|
||||||
->label('No.')
|
->label('No.')
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -449,14 +452,14 @@ class EquipmentMasterResource extends Resource
|
|||||||
->label('Import Equipment Masters')
|
->label('Import Equipment Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(EquipmentMasterImporter::class)
|
->importer(EquipmentMasterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import equipment master');
|
return Filament::auth()->user()->can('view import equipment master');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Equipment Masters')
|
->label('Export Equipment Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(EquipmentMasterExporter::class)
|
->exporter(EquipmentMasterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export equipment master');
|
return Filament::auth()->user()->can('view export equipment master');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
@@ -489,25 +492,22 @@ class EquipmentMasterResource extends Resource
|
|||||||
|
|
||||||
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
|
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
|
||||||
{
|
{
|
||||||
if (!$startDateTime || !$durationDays) {
|
if (! $startDateTime || ! $durationDays) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$startDateTimeCarbon = Carbon::parse($startDateTime);
|
$startDateTimeCarbon = Carbon::parse($startDateTime);
|
||||||
$durationDays = str_replace(',', '.', $durationDays);
|
$durationDays = str_replace(',', '.', $durationDays);
|
||||||
|
|
||||||
if(!is_numeric($durationDays))
|
if (! is_numeric($durationDays)) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
|
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
|
||||||
|
|
||||||
return $nextCalibrationDate->format('Y-m-d H:i:s');
|
return $nextCalibrationDate->format('Y-m-d H:i:s');
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,33 +5,28 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\GrMasterExporter;
|
use App\Filament\Exports\GrMasterExporter;
|
||||||
use App\Filament\Imports\GrMasterImporter;
|
use App\Filament\Imports\GrMasterImporter;
|
||||||
use App\Filament\Resources\GrMasterResource\Pages;
|
use App\Filament\Resources\GrMasterResource\Pages;
|
||||||
use App\Filament\Resources\GrMasterResource\RelationManagers;
|
|
||||||
use App\Models\GrMaster;
|
use App\Models\GrMaster;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
use Storage;
|
|
||||||
use Smalot\PdfParser\Parser;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
use setasign\Fpdi\Fpdi;
|
use setasign\Fpdi\Fpdi;
|
||||||
use setasign\Fpdi\PdfReader;
|
|
||||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
|
use Smalot\PdfParser\Parser;
|
||||||
|
use Storage;
|
||||||
|
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||||
|
|
||||||
class GrMasterResource extends Resource
|
class GrMasterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -39,6 +34,8 @@ class GrMasterResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Process Order';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
@@ -49,12 +46,13 @@ class GrMasterResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
//->relationship('item', 'id')
|
// ->relationship('item', 'id')
|
||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -62,6 +60,7 @@ class GrMasterResource extends Resource
|
|||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
@@ -72,9 +71,9 @@ class GrMasterResource extends Resource
|
|||||||
Forms\Components\TextInput::make('serial_number')
|
Forms\Components\TextInput::make('serial_number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->rule(function (callable $get) {
|
->rule(function (callable $get) {
|
||||||
return Rule::unique('gr_masters', 'serial_number')
|
return Rule::unique('gr_masters', 'serial_number')
|
||||||
->where('plant_id', $get('plant_id'))
|
->where('plant_id', $get('plant_id'))
|
||||||
->ignore($get('id')); // Ignore current record during updates
|
->ignore($get('id')); // Ignore current record during updates
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Forms\Components\FileUpload::make('attachment')
|
Forms\Components\FileUpload::make('attachment')
|
||||||
@@ -91,8 +90,7 @@ class GrMasterResource extends Resource
|
|||||||
->action(function ($get, callable $set) {
|
->action(function ($get, callable $set) {
|
||||||
$uploadedFiles = $get('attachment');
|
$uploadedFiles = $get('attachment');
|
||||||
|
|
||||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||||
{
|
|
||||||
$uploaded = reset($uploadedFiles);
|
$uploaded = reset($uploadedFiles);
|
||||||
|
|
||||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||||
@@ -100,8 +98,8 @@ class GrMasterResource extends Resource
|
|||||||
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||||
// $originalName = $uploaded->getClientOriginalName();
|
// $originalName = $uploaded->getClientOriginalName();
|
||||||
// $path = 'uploads/GRNumber/' . $originalName;
|
// $path = 'uploads/GRNumber/' . $originalName;
|
||||||
$finalFileName = $safeName . '.pdf';
|
$finalFileName = $safeName.'.pdf';
|
||||||
$finalPath = 'uploads/GRNumber/' . $finalFileName;
|
$finalPath = 'uploads/GRNumber/'.$finalFileName;
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($finalPath)) {
|
if (Storage::disk('local')->exists($finalPath)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -109,6 +107,7 @@ class GrMasterResource extends Resource
|
|||||||
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return; // Stop here
|
return; // Stop here
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,15 +117,14 @@ class GrMasterResource extends Resource
|
|||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// $fullPath = storage_path('app/' . $storedPath);
|
||||||
// $fullPath = storage_path('app/' . $storedPath);
|
$fullPath = storage_path('app/private/'.$storedPath);
|
||||||
$fullPath = storage_path('app/private/' . $storedPath);
|
$parser = new Parser;
|
||||||
$parser = new Parser();
|
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||||
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
|
||||||
$pdf = $parser->parseFile($fullPath);
|
$pdf = $parser->parseFile($fullPath);
|
||||||
$text = $pdf->getText();
|
$text = $pdf->getText();
|
||||||
|
|
||||||
//dd($text);
|
// dd($text);
|
||||||
|
|
||||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||||
$item1 = $matches[1];
|
$item1 = $matches[1];
|
||||||
@@ -136,8 +134,7 @@ class GrMasterResource extends Resource
|
|||||||
// $item2 = $matches[1];
|
// $item2 = $matches[1];
|
||||||
// dd($item2);
|
// dd($item2);
|
||||||
// }
|
// }
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Item Code Not Found')
|
->title('Item Code Not Found')
|
||||||
->body('Could not find Item code in uploaded PDF.')
|
->body('Could not find Item code in uploaded PDF.')
|
||||||
@@ -147,6 +144,7 @@ class GrMasterResource extends Resource
|
|||||||
if (Storage::disk('local')->exists($storedPath)) {
|
if (Storage::disk('local')->exists($storedPath)) {
|
||||||
Storage::disk('local')->delete($storedPath);
|
Storage::disk('local')->delete($storedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,21 +158,19 @@ class GrMasterResource extends Resource
|
|||||||
|
|
||||||
$plant = Plant::find($plant);
|
$plant = Plant::find($plant);
|
||||||
|
|
||||||
if ($item)
|
if ($item) {
|
||||||
{
|
|
||||||
$itemCode = $item->code;
|
$itemCode = $item->code;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$itemCode = null;
|
$itemCode = null;
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Item Not Found')
|
->title('Item Not Found')
|
||||||
->body("Item not found in uploaded pdf.")
|
->body('Item not found in uploaded pdf.')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
if (Storage::disk('local')->exists($storedPath)) {
|
||||||
Storage::disk('local')->delete($storedPath);
|
Storage::disk('local')->delete($storedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,220 +180,219 @@ class GrMasterResource extends Resource
|
|||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
if($itemCode == $item1)
|
if ($itemCode == $item1) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Success')
|
->title('Success')
|
||||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Item Code not matched')
|
->title('Item Code not matched')
|
||||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
if (Storage::disk('local')->exists($storedPath)) {
|
||||||
Storage::disk('local')->delete($storedPath);
|
Storage::disk('local')->delete($storedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No file selected to upload')
|
->title('No file selected to upload')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
return;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// Action::make('uploadNow1')
|
// Action::make('uploadNow1')
|
||||||
// ->label('Upload OCR')
|
// ->label('Upload OCR')
|
||||||
// ->action(function ($get, callable $set) {
|
// ->action(function ($get, callable $set) {
|
||||||
// $uploadedFiles = $get('photo');
|
// $uploadedFiles = $get('photo');
|
||||||
|
|
||||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
||||||
// {
|
// {
|
||||||
// $uploaded = reset($uploadedFiles);
|
// $uploaded = reset($uploadedFiles);
|
||||||
|
|
||||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
// if ($uploaded instanceof TemporaryUploadedFile) {
|
||||||
// $grNumber = $get('gr_number');
|
// $grNumber = $get('gr_number');
|
||||||
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||||
// // $originalName = $uploaded->getClientOriginalName();
|
// // $originalName = $uploaded->getClientOriginalName();
|
||||||
// // $path = 'uploads/GRNumber/' . $originalName;
|
// // $path = 'uploads/GRNumber/' . $originalName;
|
||||||
// $finalFileName = $safeName . '.jpg';
|
// $finalFileName = $safeName . '.jpg';
|
||||||
// $finalPath = 'uploads/OCR/' . $finalFileName;
|
// $finalPath = 'uploads/OCR/' . $finalFileName;
|
||||||
|
|
||||||
// // if (Storage::disk('local')->exists($finalPath)) {
|
// // if (Storage::disk('local')->exists($finalPath)) {
|
||||||
// // Notification::make()
|
// // Notification::make()
|
||||||
// // ->title('Duplicate File')
|
// // ->title('Duplicate File')
|
||||||
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||||
// // ->warning()
|
// // ->warning()
|
||||||
// // ->send();
|
// // ->send();
|
||||||
// // return; // Stop here
|
// // return; // Stop here
|
||||||
// // }
|
// // }
|
||||||
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
// $storedPath = $uploaded->storeAs(
|
||||||
// 'uploads/OCR',
|
// 'uploads/OCR',
|
||||||
// $finalFileName,
|
// $finalFileName,
|
||||||
// 'local'
|
// 'local'
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
||||||
// // $fullPath = storage_path('app/' . $storedPath);
|
// // $fullPath = storage_path('app/' . $storedPath);
|
||||||
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
||||||
|
|
||||||
// $fullPath = storage_path('app/private/' . $storedPath);
|
// $fullPath = storage_path('app/private/' . $storedPath);
|
||||||
|
|
||||||
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
||||||
|
|
||||||
// $rawText = $text;
|
// $rawText = $text;
|
||||||
|
|
||||||
// preg_match_all('/\d+/', $rawText, $matches);
|
// preg_match_all('/\d+/', $rawText, $matches);
|
||||||
|
|
||||||
// $serialNumbers = $matches[0];
|
// $serialNumbers = $matches[0];
|
||||||
|
|
||||||
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
||||||
|
|
||||||
// //dd($serialNumbers);
|
// //dd($serialNumbers);
|
||||||
|
|
||||||
// $processOrder = $get('gr_number');
|
// $processOrder = $get('gr_number');
|
||||||
|
|
||||||
// $itemId = $get('item_id');
|
// $itemId = $get('item_id');
|
||||||
|
|
||||||
// $plant = $get('plant_id');
|
// $plant = $get('plant_id');
|
||||||
|
|
||||||
// $item = Item::find($itemId);
|
// $item = Item::find($itemId);
|
||||||
|
|
||||||
// $plant = Plant::find($plant);
|
// $plant = Plant::find($plant);
|
||||||
|
|
||||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
||||||
|
|
||||||
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
||||||
|
|
||||||
// $storedPath = $uploaded->storeAs(
|
// $storedPath = $uploaded->storeAs(
|
||||||
// 'uploads/GRNumber',
|
// 'uploads/GRNumber',
|
||||||
// $finalFileName,
|
// $finalFileName,
|
||||||
// 'local'
|
// 'local'
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
||||||
|
|
||||||
// $templateId = $pdf->setSourceFile($templatePath);
|
// $templateId = $pdf->setSourceFile($templatePath);
|
||||||
// $templatePage = $pdf->importPage(1);
|
// $templatePage = $pdf->importPage(1);
|
||||||
|
|
||||||
// $pdf->AddPage();
|
// $pdf->AddPage();
|
||||||
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
||||||
|
|
||||||
// $pdf->SetFont('Helvetica', '', 10);
|
// $pdf->SetFont('Helvetica', '', 10);
|
||||||
// $pdf->SetTextColor(0, 0, 0);
|
// $pdf->SetTextColor(0, 0, 0);
|
||||||
|
|
||||||
// $slots = [
|
// $slots = [
|
||||||
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
|
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
|
||||||
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
|
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
|
||||||
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
|
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
|
||||||
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
|
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// $qrSlots = [
|
// $qrSlots = [
|
||||||
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
|
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
|
||||||
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
|
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
|
||||||
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
|
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
|
||||||
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
|
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// // foreach ($serialNumbers as $i => $serial) {
|
// // foreach ($serialNumbers as $i => $serial) {
|
||||||
// // if (isset($slots[$i])) {
|
// // if (isset($slots[$i])) {
|
||||||
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
|
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
|
||||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||||
// // // $pdf->Write(0, $serial);
|
// // // $pdf->Write(0, $serial);
|
||||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||||
// // }
|
// // }
|
||||||
// // }
|
// // }
|
||||||
|
|
||||||
// // $pdf->Output('F', $outputPath);
|
// // $pdf->Output('F', $outputPath);
|
||||||
// // return response()->download($outputPath);
|
// // return response()->download($outputPath);
|
||||||
|
|
||||||
// //
|
// //
|
||||||
|
|
||||||
// // foreach ($serialNumbers as $i => $serial) {
|
// // foreach ($serialNumbers as $i => $serial) {
|
||||||
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
||||||
|
|
||||||
// // //Generate QR code PNG temporarily
|
// // //Generate QR code PNG temporarily
|
||||||
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||||
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
||||||
|
|
||||||
// // //Place QR code above serial
|
// // //Place QR code above serial
|
||||||
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
||||||
|
|
||||||
// // //Erase old serial
|
// // //Erase old serial
|
||||||
// // $pdf->SetFillColor(255, 255, 255);
|
// // $pdf->SetFillColor(255, 255, 255);
|
||||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||||
|
|
||||||
// // //Write new serial number
|
// // //Write new serial number
|
||||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||||
// // }
|
// // }
|
||||||
|
|
||||||
// foreach ($serialNumbers as $i => $serial) {
|
// foreach ($serialNumbers as $i => $serial) {
|
||||||
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
||||||
|
|
||||||
// // Erase old QR completely (slightly larger)
|
// // Erase old QR completely (slightly larger)
|
||||||
// $pdf->SetFillColor(255, 255, 255);
|
// $pdf->SetFillColor(255, 255, 255);
|
||||||
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
||||||
|
|
||||||
// // Generate new QR code
|
// // Generate new QR code
|
||||||
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||||
// $qrDir = storage_path('app/private/uploads/QR');
|
// $qrDir = storage_path('app/private/uploads/QR');
|
||||||
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
||||||
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
||||||
|
|
||||||
// // Place QR code
|
// // Place QR code
|
||||||
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
||||||
|
|
||||||
// // Erase old serial
|
// // Erase old serial
|
||||||
// $pdf->SetFillColor(255, 255, 255);
|
// $pdf->SetFillColor(255, 255, 255);
|
||||||
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||||
|
|
||||||
// // Write new serial
|
// // Write new serial
|
||||||
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||||
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Save the final PDF
|
// // Save the final PDF
|
||||||
// $pdf->Output('F', $outputPath);
|
// $pdf->Output('F', $outputPath);
|
||||||
|
|
||||||
// // Download
|
// // Download
|
||||||
// return response()->download($outputPath);
|
// return response()->download($outputPath);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// Notification::make()
|
// Notification::make()
|
||||||
// ->title('No file selected to upload')
|
// ->title('No file selected to upload')
|
||||||
// ->warning()
|
// ->warning()
|
||||||
// ->send();
|
// ->send();
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// }),
|
// }),
|
||||||
|
|
||||||
Action::make('downloadAttachment')
|
Action::make('downloadAttachment')
|
||||||
->label('Download PDF')
|
->label('Download PDF')
|
||||||
->action(function ($get) {
|
->action(function ($get) {
|
||||||
$equipmentNumber = $get('gr_number');
|
$equipmentNumber = $get('gr_number');
|
||||||
|
|
||||||
if (!$equipmentNumber) {
|
if (! $equipmentNumber) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No GR Number entered')
|
->title('No GR Number entered')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,17 +406,18 @@ class GrMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$fileToDownload) {
|
if (! $fileToDownload) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('PDF not found for this process order')
|
->title('PDF not found for this process order')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
->default(Filament::auth()->user()?->name),
|
->default(Filament::auth()->user()?->name),
|
||||||
@@ -440,6 +436,7 @@ class GrMasterResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -506,14 +503,14 @@ class GrMasterResource extends Resource
|
|||||||
->label('Import GR Masters')
|
->label('Import GR Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(GrMasterImporter::class)
|
->importer(GrMasterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import gr master');
|
return Filament::auth()->user()->can('view import gr master');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export GR Masters')
|
->label('Export GR Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(GrMasterExporter::class)
|
->exporter(GrMasterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export gr master');
|
return Filament::auth()->user()->can('view export gr master');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\GuardNameExporter;
|
use App\Filament\Exports\GuardNameExporter;
|
||||||
use App\Filament\Imports\GuardNameImporter;
|
use App\Filament\Imports\GuardNameImporter;
|
||||||
use App\Filament\Resources\GuardNameResource\Pages;
|
use App\Filament\Resources\GuardNameResource\Pages;
|
||||||
use App\Filament\Resources\GuardNameResource\RelationManagers;
|
|
||||||
use App\Models\GuardName;
|
use App\Models\GuardName;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -42,20 +41,20 @@ class GuardNameResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(GuardName::latest()->first())->plant_id;
|
return optional(GuardName::latest()->first())->plant_id;
|
||||||
})
|
})
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('GnError', 'Please select a plant first.');
|
$set('GnError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('GnError', null);
|
$set('GnError', null);
|
||||||
$set('created_by', Filament::auth()->user()?->name);
|
$set('created_by', Filament::auth()->user()?->name);
|
||||||
}
|
}
|
||||||
@@ -113,6 +112,7 @@ class GuardNameResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
// Tables\Columns\TextColumn::make('id')
|
// Tables\Columns\TextColumn::make('id')
|
||||||
@@ -169,14 +169,14 @@ class GuardNameResource extends Resource
|
|||||||
->label('Import Guard Names')
|
->label('Import Guard Names')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(GuardNameImporter::class)
|
->importer(GuardNameImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import guard name');
|
return Filament::auth()->user()->can('view import guard name');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Guard Names')
|
->label('Export Guard Names')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(GuardNameExporter::class)
|
->exporter(GuardNameExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export guard name');
|
return Filament::auth()->user()->can('view export guard name');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class GuardPatrolEntryResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||||
|
|||||||
@@ -4,24 +4,21 @@ namespace App\Filament\Resources;
|
|||||||
|
|
||||||
use App\Filament\Exports\InvoiceInTransitExporter;
|
use App\Filament\Exports\InvoiceInTransitExporter;
|
||||||
use App\Filament\Resources\InvoiceInTransitResource\Pages;
|
use App\Filament\Resources\InvoiceInTransitResource\Pages;
|
||||||
use App\Filament\Resources\InvoiceInTransitResource\RelationManagers;
|
|
||||||
use App\Models\InvoiceInTransit;
|
use App\Models\InvoiceInTransit;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\FileUpload;
|
|
||||||
use Storage;
|
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Storage;
|
||||||
use Carbon\Carbon;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
|
|
||||||
|
|
||||||
class InvoiceInTransitResource extends Resource
|
class InvoiceInTransitResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -37,6 +34,11 @@ class InvoiceInTransitResource extends Resource
|
|||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('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();
|
||||||
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('receiving_plant')
|
Forms\Components\TextInput::make('receiving_plant')
|
||||||
->label('Receiving Plant'),
|
->label('Receiving Plant'),
|
||||||
@@ -272,8 +274,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
|
|
||||||
$fullPath = Storage::disk('local')->path($path);
|
$fullPath = Storage::disk('local')->path($path);
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
if ($fullPath && file_exists($fullPath)) {
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
$rows = Excel::toArray(null, $fullPath)[0];
|
||||||
|
|
||||||
if ((count($rows) - 1) <= 0) {
|
if ((count($rows) - 1) <= 0) {
|
||||||
@@ -305,7 +306,6 @@ class InvoiceInTransitResource extends Resource
|
|||||||
$invalidLRBLAWDt = [];
|
$invalidLRBLAWDt = [];
|
||||||
$invalidPenDay = [];
|
$invalidPenDay = [];
|
||||||
|
|
||||||
|
|
||||||
foreach ($rows as $index => $row) {
|
foreach ($rows as $index => $row) {
|
||||||
if ($index == 0) {
|
if ($index == 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -369,7 +369,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
//$plantId = $plant->id;
|
// $plantId = $plant->id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,8 +470,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
|
||||||
if ($index == 0) {
|
if ($index == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -504,8 +503,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($invoiceDt))
|
if (! empty($invoiceDt)) {
|
||||||
{
|
|
||||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $invoiceDt)) {
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $invoiceDt)) {
|
||||||
[$day, $month, $year] = preg_split('/[-\/]/', $invoiceDt);
|
[$day, $month, $year] = preg_split('/[-\/]/', $invoiceDt);
|
||||||
$formattedDate = "{$year}-{$month}-{$day}";
|
$formattedDate = "{$year}-{$month}-{$day}";
|
||||||
@@ -517,8 +515,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
} else {
|
} else {
|
||||||
$formattedDate = null;
|
$formattedDate = null;
|
||||||
}
|
}
|
||||||
if (! empty($LRBAWDt))
|
if (! empty($LRBAWDt)) {
|
||||||
{
|
|
||||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $LRBAWDt)) {
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $LRBAWDt)) {
|
||||||
[$day, $month, $year] = preg_split('/[-\/]/', $LRBAWDt);
|
[$day, $month, $year] = preg_split('/[-\/]/', $LRBAWDt);
|
||||||
$formattedDt = "{$year}-{$month}-{$day}";
|
$formattedDt = "{$year}-{$month}-{$day}";
|
||||||
@@ -530,8 +527,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
} else {
|
} else {
|
||||||
$formattedDt = null;
|
$formattedDt = null;
|
||||||
}
|
}
|
||||||
if (! empty($OBDDate))
|
if (! empty($OBDDate)) {
|
||||||
{
|
|
||||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
|
||||||
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
|
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
|
||||||
$formattedDate = "{$year}-{$month}-{$day}";
|
$formattedDate = "{$year}-{$month}-{$day}";
|
||||||
@@ -577,15 +573,15 @@ class InvoiceInTransitResource extends Resource
|
|||||||
->body('Invoice in transit uploaded successfully!')
|
->body('Invoice in transit uploaded successfully!')
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Insertion Failed')
|
->title('Insertion Failed')
|
||||||
->body('Invoice in transit upload failed!')
|
->body('Invoice in transit upload failed!')
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ItemResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Item::latest()->first())->plant_id;
|
return optional(Item::latest()->first())->plant_id;
|
||||||
@@ -251,7 +251,7 @@ class ItemResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
@@ -394,7 +394,7 @@ class ItemResource extends Resource
|
|||||||
// // ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
// // ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||||
// ->options(function (callable $get) {
|
// ->options(function (callable $get) {
|
||||||
// $userHas = Filament::auth()->user()->plant_id;
|
// $userHas = Filament::auth()->user()->plant_id;
|
||||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
// })
|
// })
|
||||||
// ->label('Select Plant')
|
// ->label('Select Plant')
|
||||||
// ->required()
|
// ->required()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,7 @@ class LocatorResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Locator::latest()->first())->plant_id;
|
return optional(Locator::latest()->first())->plant_id;
|
||||||
@@ -194,7 +194,7 @@ class LocatorResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class MachineResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(Machine::latest()->first())->plant_id;
|
return optional(Machine::latest()->first())->plant_id;
|
||||||
|
|||||||
@@ -5,21 +5,20 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\MfmMeterExporter;
|
use App\Filament\Exports\MfmMeterExporter;
|
||||||
use App\Filament\Imports\MfmMeterImporter;
|
use App\Filament\Imports\MfmMeterImporter;
|
||||||
use App\Filament\Resources\MfmMeterResource\Pages;
|
use App\Filament\Resources\MfmMeterResource\Pages;
|
||||||
use App\Filament\Resources\MfmMeterResource\RelationManagers;
|
|
||||||
use App\Models\DeviceMaster;
|
use App\Models\DeviceMaster;
|
||||||
use App\Models\MfmMeter;
|
use App\Models\MfmMeter;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class MfmMeterResource extends Resource
|
class MfmMeterResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -34,35 +33,37 @@ class MfmMeterResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
}),
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
Forms\Components\Select::make('device_master_id')
|
}),
|
||||||
//->relationship('device', 'name')
|
Forms\Components\Select::make('device_master_id')
|
||||||
->options(function ($get) {
|
// ->relationship('device', 'name')
|
||||||
$plantId = $get('plant_id');
|
->options(function ($get) {
|
||||||
if (!$plantId) {
|
$plantId = $get('plant_id');
|
||||||
return [];
|
if (! $plantId) {
|
||||||
}
|
return [];
|
||||||
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
}
|
||||||
})
|
|
||||||
->label('Device Name')
|
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
||||||
->required(),
|
})
|
||||||
Forms\Components\TextInput::make('sequence')
|
->label('Device Name')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('sequence')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\TextInput::make('name')
|
||||||
->default(Filament::auth()->user()?->name),
|
->required(),
|
||||||
])
|
Forms\Components\Hidden::make('created_by')
|
||||||
->columns(4),
|
->default(Filament::auth()->user()?->name),
|
||||||
|
])
|
||||||
|
->columns(4),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -71,12 +72,13 @@ class MfmMeterResource extends Resource
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('No.')
|
Tables\Columns\TextColumn::make('No.')
|
||||||
->label('No.')
|
->label('No.')
|
||||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -121,19 +123,19 @@ class MfmMeterResource extends Resource
|
|||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import MFM Meters')
|
->label('Import MFM Meters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(MfmMeterImporter::class)
|
->importer(MfmMeterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import mfm meter');
|
return Filament::auth()->user()->can('view import mfm meter');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export MFM Meters')
|
->label('Export MFM Meters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(MfmMeterExporter::class)
|
->exporter(MfmMeterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export mfm meter');
|
return Filament::auth()->user()->can('view export mfm meter');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -5,127 +5,128 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\MfmParameterExporter;
|
use App\Filament\Exports\MfmParameterExporter;
|
||||||
use App\Filament\Imports\MfmParameterImporter;
|
use App\Filament\Imports\MfmParameterImporter;
|
||||||
use App\Filament\Resources\MfmParameterResource\Pages;
|
use App\Filament\Resources\MfmParameterResource\Pages;
|
||||||
use App\Filament\Resources\MfmParameterResource\RelationManagers;
|
|
||||||
use App\Models\MfmParameter;
|
use App\Models\MfmParameter;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
class MfmParameterResource extends Resource
|
class MfmParameterResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = MfmParameter::class;
|
protected static ?string $model = MfmParameter::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Power House';
|
protected static ?string $navigationGroup = 'Power House';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('device_master_id', null);
|
|
||||||
$set('mfm_meter_id', null);
|
|
||||||
$set('name', null);
|
|
||||||
$set('register_id', null);
|
|
||||||
$set('identifier', null);
|
|
||||||
$set('byte_to_convert', null);
|
|
||||||
$set('type_to_convert', null);
|
|
||||||
$set('decimal_to_display', null);
|
|
||||||
})
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('device_master_id')
|
|
||||||
->label('Device Master')
|
|
||||||
//->relationship('deviceName', 'name')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
|
|
||||||
if (!$plantId) {
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
return [];
|
})
|
||||||
}
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('device_master_id', null);
|
||||||
|
$set('mfm_meter_id', null);
|
||||||
|
$set('name', null);
|
||||||
|
$set('register_id', null);
|
||||||
|
$set('identifier', null);
|
||||||
|
$set('byte_to_convert', null);
|
||||||
|
$set('type_to_convert', null);
|
||||||
|
$set('decimal_to_display', null);
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('device_master_id')
|
||||||
|
->label('Device Master')
|
||||||
|
// ->relationship('deviceName', 'name')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
return \App\Models\DeviceMaster::where('plant_id', $plantId)
|
if (! $plantId) {
|
||||||
->pluck('name', 'id');
|
return [];
|
||||||
})
|
}
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('mfm_meter_id', null);
|
|
||||||
$set('name', null);
|
|
||||||
$set('register_id', null);
|
|
||||||
$set('identifier', null);
|
|
||||||
$set('byte_to_convert', null);
|
|
||||||
$set('type_to_convert', null);
|
|
||||||
$set('decimal_to_display', null);
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('mfm_meter_id')
|
|
||||||
->label('Mfm Meter')
|
|
||||||
// ->relationship('mfmMeter', 'sequence')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
|
|
||||||
if (!$plantId) {
|
return \App\Models\DeviceMaster::where('plant_id', $plantId)
|
||||||
return [];
|
->pluck('name', 'id');
|
||||||
}
|
})
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('mfm_meter_id', null);
|
||||||
|
$set('name', null);
|
||||||
|
$set('register_id', null);
|
||||||
|
$set('identifier', null);
|
||||||
|
$set('byte_to_convert', null);
|
||||||
|
$set('type_to_convert', null);
|
||||||
|
$set('decimal_to_display', null);
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('mfm_meter_id')
|
||||||
|
->label('Mfm Meter')
|
||||||
|
// ->relationship('mfmMeter', 'sequence')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
return \App\Models\MfmMeter::where('plant_id', $plantId)
|
if (! $plantId) {
|
||||||
->pluck('sequence', 'id');
|
return [];
|
||||||
})
|
}
|
||||||
->afterStateUpdated(function (callable $set) {
|
|
||||||
$set('name', null);
|
return \App\Models\MfmMeter::where('plant_id', $plantId)
|
||||||
$set('register_id', null);
|
->pluck('sequence', 'id');
|
||||||
$set('identifier', null);
|
})
|
||||||
$set('byte_to_convert', null);
|
->afterStateUpdated(function (callable $set) {
|
||||||
$set('type_to_convert', null);
|
$set('name', null);
|
||||||
$set('decimal_to_display', null);
|
$set('register_id', null);
|
||||||
})
|
$set('identifier', null);
|
||||||
->reactive()
|
$set('byte_to_convert', null);
|
||||||
->required(),
|
$set('type_to_convert', null);
|
||||||
Forms\Components\TextInput::make('name')
|
$set('decimal_to_display', null);
|
||||||
->label('Parameter Name')
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('register_id')
|
Forms\Components\TextInput::make('name')
|
||||||
->label('Register ID')
|
->label('Parameter Name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('identifier')
|
Forms\Components\TextInput::make('register_id')
|
||||||
->label('Identifier')
|
->label('Register ID')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TextInput::make('byte_to_convert')
|
Forms\Components\TextInput::make('identifier')
|
||||||
->label('Byte To Convert')
|
->label('Identifier')
|
||||||
->reactive()
|
->reactive()
|
||||||
->default(2)
|
->required(),
|
||||||
->required(),
|
Forms\Components\TextInput::make('byte_to_convert')
|
||||||
Forms\Components\TextInput::make('type_to_convert')
|
->label('Byte To Convert')
|
||||||
->label('Type To Convert')
|
->reactive()
|
||||||
->required(),
|
->default(2)
|
||||||
Forms\Components\TextInput::make('decimal_to_display')
|
->required(),
|
||||||
->label('Decimal To Display')
|
Forms\Components\TextInput::make('type_to_convert')
|
||||||
->reactive()
|
->label('Type To Convert')
|
||||||
->default(1)
|
->required(),
|
||||||
->required(),
|
Forms\Components\TextInput::make('decimal_to_display')
|
||||||
|
->label('Decimal To Display')
|
||||||
|
->reactive()
|
||||||
|
->default(1)
|
||||||
|
->required(),
|
||||||
])
|
])
|
||||||
->columns(3),
|
->columns(3),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,6 +140,7 @@ class MfmParameterResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -212,14 +214,14 @@ class MfmParameterResource extends Resource
|
|||||||
->label('Import MFM Parameters')
|
->label('Import MFM Parameters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(MfmParameterImporter::class)
|
->importer(MfmParameterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import mfm parameter');
|
return Filament::auth()->user()->can('view import mfm parameter');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export MFM Parameters')
|
->label('Export MFM Parameters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(MfmParameterExporter::class)
|
->exporter(MfmParameterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export mfm parameter');
|
return Filament::auth()->user()->can('view export mfm parameter');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Filament\Resources\MfmReadingResource\Pages;
|
use App\Filament\Resources\MfmReadingResource\Pages;
|
||||||
use App\Filament\Resources\MfmReadingResource\RelationManagers;
|
|
||||||
use App\Models\MfmReading;
|
use App\Models\MfmReading;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -31,7 +30,8 @@ class MfmReadingResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('mfm_meter_id')
|
Forms\Components\Select::make('mfm_meter_id')
|
||||||
@@ -72,6 +72,7 @@ class MfmReadingResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -127,9 +128,9 @@ class MfmReadingResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('current_y')
|
Tables\Columns\TextColumn::make('current_y')
|
||||||
->label('Current Y')
|
->label('Current Y')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('current_b')
|
Tables\Columns\TextColumn::make('current_b')
|
||||||
->label('Current B')
|
->label('Current B')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(MotorTestingMaster::latest()->first())->plant_id;
|
return optional(MotorTestingMaster::latest()->first())->plant_id;
|
||||||
@@ -466,7 +466,7 @@ class MotorTestingMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -3,36 +3,36 @@
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Filament\Resources\OcrValidationResource\Pages;
|
use App\Filament\Resources\OcrValidationResource\Pages;
|
||||||
use App\Filament\Resources\OcrValidationResource\RelationManagers;
|
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\OcrValidation;
|
use App\Models\OcrValidation;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Actions\Action;
|
||||||
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
|
||||||
use setasign\Fpdi\Fpdi;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
use setasign\Fpdi\PdfReader;
|
use setasign\Fpdi\Fpdi;
|
||||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
use Storage;
|
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
|
||||||
use Smalot\PdfParser\Parser;
|
use Smalot\PdfParser\Parser;
|
||||||
|
use Storage;
|
||||||
|
|
||||||
class OcrValidationResource extends Resource
|
class OcrValidationResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = OcrValidation::class;
|
protected static ?string $model = OcrValidation::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-s-qr-code';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'OCR';
|
||||||
|
|
||||||
public $camera_capture;
|
public $camera_capture;
|
||||||
|
|
||||||
public $serialNumbers = [];
|
public $serialNumbers = [];
|
||||||
|
|
||||||
use InteractsWithForms;
|
use InteractsWithForms;
|
||||||
@@ -47,12 +47,13 @@ class OcrValidationResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
//->relationship('item', 'id')
|
// ->relationship('item', 'id')
|
||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
@@ -60,6 +61,7 @@ class OcrValidationResource extends Resource
|
|||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
@@ -109,13 +111,12 @@ class OcrValidationResource extends Resource
|
|||||||
->preserveFilenames()
|
->preserveFilenames()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Forms\Components\Actions::make([
|
Forms\Components\Actions::make([
|
||||||
Action::make('uploadNow')
|
Action::make('uploadNow')
|
||||||
->label('Upload PDF Now')
|
->label('Upload PDF Now')
|
||||||
->action(function ($get, callable $set) {
|
->action(function ($get, callable $set) {
|
||||||
$uploadedFiles = $get('attachment');
|
$uploadedFiles = $get('attachment');
|
||||||
|
|
||||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||||
{
|
|
||||||
$uploaded = reset($uploadedFiles);
|
$uploaded = reset($uploadedFiles);
|
||||||
|
|
||||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||||
@@ -123,8 +124,8 @@ class OcrValidationResource extends Resource
|
|||||||
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||||
// $originalName = $uploaded->getClientOriginalName();
|
// $originalName = $uploaded->getClientOriginalName();
|
||||||
// $path = 'uploads/GRNumber/' . $originalName;
|
// $path = 'uploads/GRNumber/' . $originalName;
|
||||||
$finalFileName = $safeName . '.pdf';
|
$finalFileName = $safeName.'.pdf';
|
||||||
$finalPath = 'uploads/OcrGrNumber/' . $finalFileName;
|
$finalPath = 'uploads/OcrGrNumber/'.$finalFileName;
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($finalPath)) {
|
if (Storage::disk('local')->exists($finalPath)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -132,6 +133,7 @@ class OcrValidationResource extends Resource
|
|||||||
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,26 +143,22 @@ class OcrValidationResource extends Resource
|
|||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// $fullPath = storage_path('app/' . $storedPath);
|
||||||
// $fullPath = storage_path('app/' . $storedPath);
|
$fullPath = storage_path('app/private/'.$storedPath);
|
||||||
$fullPath = storage_path('app/private/' . $storedPath);
|
$parser = new Parser;
|
||||||
$parser = new Parser();
|
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||||
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
|
||||||
$pdf = $parser->parseFile($fullPath);
|
$pdf = $parser->parseFile($fullPath);
|
||||||
$text = $pdf->getText();
|
$text = $pdf->getText();
|
||||||
|
|
||||||
// dd($text);
|
// dd($text);
|
||||||
|
|
||||||
//dd($text);
|
// dd($text);
|
||||||
$item1 = null;
|
$item1 = null;
|
||||||
$item2 = null;
|
$item2 = null;
|
||||||
|
|
||||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches))
|
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||||
{
|
|
||||||
$item1 = $matches[1];
|
$item1 = $matches[1];
|
||||||
}
|
} elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
|
||||||
else if (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches))
|
|
||||||
{
|
|
||||||
$item2 = $matches[1];
|
$item2 = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,21 +172,19 @@ class OcrValidationResource extends Resource
|
|||||||
|
|
||||||
$plant = Plant::find($plant);
|
$plant = Plant::find($plant);
|
||||||
|
|
||||||
if ($item)
|
if ($item) {
|
||||||
{
|
|
||||||
$itemCode = $item->code;
|
$itemCode = $item->code;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$itemCode = null;
|
$itemCode = null;
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Item Not Found')
|
->title('Item Not Found')
|
||||||
->body("Item not found in uploaded pdf.")
|
->body('Item not found in uploaded pdf.')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
if (Storage::disk('local')->exists($storedPath)) {
|
||||||
Storage::disk('local')->delete($storedPath);
|
Storage::disk('local')->delete($storedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,50 +194,48 @@ class OcrValidationResource extends Resource
|
|||||||
'local'
|
'local'
|
||||||
);
|
);
|
||||||
|
|
||||||
if($itemCode == $item1)
|
if ($itemCode == $item1) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Success')
|
->title('Success')
|
||||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($itemCode == $item2)
|
if ($itemCode == $item2) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Success')
|
->title('Success')
|
||||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Item Code not matched')
|
->title('Item Code not matched')
|
||||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($storedPath)) {
|
if (Storage::disk('local')->exists($storedPath)) {
|
||||||
Storage::disk('local')->delete($storedPath);
|
Storage::disk('local')->delete($storedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No file selected to upload')
|
->title('No file selected to upload')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
return;
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Action::make('uploadNow1')
|
Action::make('uploadNow1')
|
||||||
->label('Upload OCR')
|
->label('Upload OCR')
|
||||||
->action(function ($get, callable $set) {
|
->action(function ($get, callable $set) {
|
||||||
|
|
||||||
@@ -256,25 +250,25 @@ class OcrValidationResource extends Resource
|
|||||||
->title('Serial numbers cannot be empty!')
|
->title('Serial numbers cannot be empty!')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$serialNumbers = array_slice($serialNumbers, 0, 4);
|
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
||||||
|
|
||||||
if (count($serials) == 1)
|
if (count($serials) == 1) {
|
||||||
{
|
|
||||||
$serialNumbers = $serials;
|
$serialNumbers = $serials;
|
||||||
$grNumber = trim($grNumber);
|
$grNumber = trim($grNumber);
|
||||||
|
|
||||||
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
|
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
|
||||||
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
|
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
|
||||||
|
|
||||||
if(!file_exists($templatePath))
|
if (! file_exists($templatePath)) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Template PDF not found for the Gr Number $grNumber.")
|
->title("Template PDF not found for the Gr Number $grNumber.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,17 +294,21 @@ class OcrValidationResource extends Resource
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($serialNumbers as $i => $serial) {
|
foreach ($serialNumbers as $i => $serial) {
|
||||||
if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
if (! isset($slots[$i]) || ! isset($qrSlots[$i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Erase old QR completely (slightly larger)
|
// Erase old QR completely (slightly larger)
|
||||||
$pdf->SetFillColor(255, 255, 255);
|
$pdf->SetFillColor(255, 255, 255);
|
||||||
$pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
$pdf->Rect($qrSlots[$i]['x'] - 1, $qrSlots[$i]['y'] - 1, $qrSlots[$i]['size'] + 2, $qrSlots[$i]['size'] + 2, 'F');
|
||||||
|
|
||||||
// Generate new QR code
|
// Generate new QR code
|
||||||
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||||
$qrDir = storage_path('app/private/uploads/QR');
|
$qrDir = storage_path('app/private/uploads/QR');
|
||||||
if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
if (! file_exists($qrDir)) {
|
||||||
//QrCode::format('svg')->size(100)->generate($serial, $qrPath);
|
mkdir($qrDir, 0777, true);
|
||||||
|
}
|
||||||
|
// QrCode::format('svg')->size(100)->generate($serial, $qrPath);
|
||||||
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
|
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
|
||||||
|
|
||||||
// Place QR code
|
// Place QR code
|
||||||
@@ -331,12 +329,11 @@ class OcrValidationResource extends Resource
|
|||||||
// Download
|
// Download
|
||||||
return response()->download($outputPath);
|
return response()->download($outputPath);
|
||||||
}
|
}
|
||||||
if(count($serials) == 4)
|
if (count($serials) == 4) {
|
||||||
{
|
|
||||||
|
|
||||||
$serialNumbers = array_slice($serials, 0, 4);
|
$serialNumbers = array_slice($serials, 0, 4);
|
||||||
|
|
||||||
//dd($serialNumbers);
|
// dd($serialNumbers);
|
||||||
|
|
||||||
$itemId = $get('item_id');
|
$itemId = $get('item_id');
|
||||||
|
|
||||||
@@ -348,19 +345,19 @@ class OcrValidationResource extends Resource
|
|||||||
|
|
||||||
$grNumber = trim($grNumber);
|
$grNumber = trim($grNumber);
|
||||||
|
|
||||||
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
|
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
|
||||||
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
|
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
|
||||||
|
|
||||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
||||||
|
|
||||||
//$templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf");
|
// $templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf");
|
||||||
|
|
||||||
if(!file_exists($templatePath))
|
if (! file_exists($templatePath)) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Template PDF not found for the Gr Number $grNumber.")
|
->title("Template PDF not found for the Gr Number $grNumber.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,17 +395,21 @@ class OcrValidationResource extends Resource
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($serialNumbers as $i => $serial) {
|
foreach ($serialNumbers as $i => $serial) {
|
||||||
if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
if (! isset($slots[$i]) || ! isset($qrSlots[$i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Erase old QR completely (slightly larger)
|
// Erase old QR completely (slightly larger)
|
||||||
$pdf->SetFillColor(255, 255, 255);
|
$pdf->SetFillColor(255, 255, 255);
|
||||||
$pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
$pdf->Rect($qrSlots[$i]['x'] - 1, $qrSlots[$i]['y'] - 1, $qrSlots[$i]['size'] + 2, $qrSlots[$i]['size'] + 2, 'F');
|
||||||
|
|
||||||
// Generate new QR code
|
// Generate new QR code
|
||||||
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||||
$qrDir = storage_path('app/private/uploads/QR');
|
$qrDir = storage_path('app/private/uploads/QR');
|
||||||
if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
if (! file_exists($qrDir)) {
|
||||||
//QrCode::format('svg')->size(100)->generate($serial, $qrPath);
|
mkdir($qrDir, 0777, true);
|
||||||
|
}
|
||||||
|
// QrCode::format('svg')->size(100)->generate($serial, $qrPath);
|
||||||
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
|
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
|
||||||
|
|
||||||
// Place QR code
|
// Place QR code
|
||||||
@@ -428,13 +429,12 @@ class OcrValidationResource extends Resource
|
|||||||
|
|
||||||
// Download
|
// Download
|
||||||
return response()->download($outputPath);
|
return response()->download($outputPath);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Please capture either 1 or 4 serial numbers.')
|
->title('Please capture either 1 or 4 serial numbers.')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -443,11 +443,12 @@ class OcrValidationResource extends Resource
|
|||||||
->action(function ($get) {
|
->action(function ($get) {
|
||||||
$equipmentNumber = $get('gr_number');
|
$equipmentNumber = $get('gr_number');
|
||||||
|
|
||||||
if (!$equipmentNumber) {
|
if (! $equipmentNumber) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('No GR Number entered')
|
->title('No GR Number entered')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,16 +462,18 @@ class OcrValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$fileToDownload) {
|
if (! $fileToDownload) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('PDF not found for this process order')
|
->title('PDF not found for this process order')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
Forms\Components\Field::make('camera_capture')
|
Forms\Components\Field::make('camera_capture')
|
||||||
->view('fields.camera-capture'),
|
->view('fields.camera-capture'),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
@@ -481,7 +484,6 @@ class OcrValidationResource extends Resource
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class PalletValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
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) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('pallet_number', null);
|
$set('pallet_number', null);
|
||||||
@@ -279,7 +279,7 @@ class PalletValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
@@ -529,7 +529,7 @@ class PalletValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class ProductionLineStopResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(ProductionLineStop::latest()->first())->plant_id;
|
return optional(ProductionLineStop::latest()->first())->plant_id;
|
||||||
@@ -430,7 +430,7 @@ class ProductionLineStopResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(ProductionPlan::latest()->first())->plant_id;
|
return optional(ProductionPlan::latest()->first())->plant_id;
|
||||||
@@ -576,7 +576,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
|
||||||
->default(function () {
|
->default(function () {
|
||||||
@@ -1035,7 +1035,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class QualityValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
@@ -3015,7 +3015,7 @@ class QualityValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
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) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -456,7 +456,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class SerialValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(SerialValidation::latest()->first())->plant_id;
|
return optional(SerialValidation::latest()->first())->plant_id;
|
||||||
@@ -332,7 +332,7 @@ class SerialValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->required()
|
->required()
|
||||||
@@ -1038,7 +1038,7 @@ class SerialValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ use App\Models\Shift;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class ShiftResource extends Resource
|
class ShiftResource extends Resource
|
||||||
@@ -39,232 +39,229 @@ class ShiftResource extends Resource
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
->reactive()
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
})
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
->default(function () {
|
})
|
||||||
return optional(Shift::latest()->first())->plant_id;
|
->default(function () {
|
||||||
})
|
return optional(Shift::latest()->first())->plant_id;
|
||||||
->disabled(fn (Get $get) => !empty($get('id')))
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$set('block_id', null);
|
$set('block_id', null);
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('sPlantError', 'Please select a plant first.');
|
$set('sPlantError', 'Please select a plant first.');
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('sPlantError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('sPlantError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('sPlantError') ? $get('sPlantError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required()
|
|
||||||
// ->nullable()
|
|
||||||
->reactive()
|
|
||||||
->default(function () {
|
|
||||||
return optional(Shift::latest()->first())->block_id;
|
|
||||||
})
|
|
||||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
|
||||||
// ->options(fn (callable $get) =>
|
|
||||||
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
|
||||||
// ->pluck('name', 'id')
|
|
||||||
// ->toArray() // Convert collection to array
|
|
||||||
// )
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (!$get('plant_id')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return \App\Models\Block::where('plant_id', $get('plant_id'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('name', null))
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$blockId = $get('block_id');
|
|
||||||
$set('name', null);
|
|
||||||
if (!$blockId) {
|
|
||||||
$set('sBlockError', 'Please select a block first.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('sBlockError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('sBlockError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('sBlockError') ? $get('sBlockError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->placeholder('Scan the valid name')
|
|
||||||
->autofocus(true)
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$nameId = $get('name');
|
|
||||||
$set('start_time', null);
|
|
||||||
if (!$nameId) {
|
|
||||||
$set('sNameError', 'Scan the valid name.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// $exists = Shift::where('plant_id', $get('plant_id'))
|
|
||||||
// ->where('block_id', $get('block_id'))
|
|
||||||
// ->where('name', $nameId)
|
|
||||||
// ->latest()
|
|
||||||
// ->exists();
|
|
||||||
// if ($exists)
|
|
||||||
// {
|
|
||||||
// $set('start_time', null);
|
|
||||||
// $set('sNameError', 'Scanned name already exist.');
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
$set('sNameError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('sNameError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('sNameError') ? $get('sNameError') : null)
|
|
||||||
->hintColor('danger')
|
|
||||||
->rule(function (callable $get) {
|
|
||||||
return Rule::unique('shifts', 'name')
|
|
||||||
->where('plant_id', $get('plant_id'))
|
|
||||||
->where('block_id', $get('block_id'))
|
|
||||||
->ignore($get('id')); // Ignore current record during updates
|
|
||||||
}),
|
|
||||||
Forms\Components\TimePicker::make('start_time')
|
|
||||||
->required()
|
|
||||||
->label('Start Time')
|
|
||||||
->live()
|
|
||||||
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
|
||||||
// $set('end_time', self::calculateEndTime($state, $get('duration')))
|
|
||||||
// )
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$startTime = $get('start_time');
|
|
||||||
$set('duration', null);
|
|
||||||
$set('end_time', self::calculateEndTime($state, $get('duration')));
|
|
||||||
if (!$startTime) {
|
|
||||||
$set('sStartTimeError', 'Choose the valid start time.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// $exists = Shift::where('plant_id', $get('plant_id'))
|
|
||||||
// ->where('block_id', $get('block_id'))
|
|
||||||
// ->where('name', $get('name'))
|
|
||||||
// ->latest()
|
|
||||||
// ->exists();
|
|
||||||
// if ($exists)
|
|
||||||
// {
|
|
||||||
// $set('start_time', null);
|
|
||||||
// $set('sStartTimeError', null);
|
|
||||||
// $set('sNameError', 'Scanned name already exist.');
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
$set('sStartTimeError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('sStartTimeError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('sStartTimeError') ? $get('sStartTimeError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\TextInput::make('duration')
|
|
||||||
->required()
|
|
||||||
->placeholder('Scan the valid duration')
|
|
||||||
->numeric()
|
|
||||||
->inputMode('decimal')
|
|
||||||
->minValue(0.01) // Minimum valid duration
|
|
||||||
->lazy()
|
|
||||||
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
|
||||||
// $set('end_time', self::calculateEndTime($get('start_time'), $state))
|
|
||||||
// )
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
$duration = $get('duration');
|
|
||||||
// $set('end_time', null);
|
|
||||||
$set('end_time', self::calculateEndTime($get('start_time'), $state));
|
|
||||||
if (!$duration) {
|
|
||||||
$set('sDurationError', 'Scan the valid duration.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[$hRs, $miNs] = explode('.', $duration) + [0, 0]; // Ensure two parts
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
$miNs = (int) $miNs;
|
|
||||||
|
|
||||||
$set('duration', $hRs.'.'.$miNs);
|
|
||||||
|
|
||||||
if ($miNs > 60) {
|
|
||||||
$set('sDurationError', 'Minutes exceeds 1 hour.');
|
|
||||||
$set('duration', null);
|
|
||||||
$set('end_time', null);
|
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
$set('sPlantError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('sPlantError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('sPlantError') ? $get('sPlantError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Select::make('block_id')
|
||||||
|
->relationship('block', 'name')
|
||||||
|
->required()
|
||||||
|
// ->nullable()
|
||||||
|
->reactive()
|
||||||
|
->default(function () {
|
||||||
|
return optional(Shift::latest()->first())->block_id;
|
||||||
|
})
|
||||||
|
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (! $get('plant_id')) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
return \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
// ->afterStateUpdated(fn ($set) => $set('name', null))
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$blockId = $get('block_id');
|
||||||
|
$set('name', null);
|
||||||
|
if (! $blockId) {
|
||||||
|
$set('sBlockError', 'Please select a block first.');
|
||||||
|
|
||||||
if ($totalMinutes > 1440) {
|
|
||||||
$set('sDurationError', 'Duration exceeds 24 hours.');
|
|
||||||
$set('duration', null);
|
|
||||||
$set('end_time', null);
|
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
$set('sBlockError', null);
|
||||||
}
|
}
|
||||||
$set('sDurationError', null);
|
})
|
||||||
}
|
->extraAttributes(fn ($get) => [
|
||||||
})
|
'class' => $get('sBlockError') ? 'border-red-500' : '',
|
||||||
->extraAttributes(fn ($get) => [
|
])
|
||||||
'class' => $get('sDurationError') ? 'border-red-500' : '',
|
->hint(fn ($get) => $get('sBlockError') ? $get('sBlockError') : null)
|
||||||
])
|
->hintColor('danger'),
|
||||||
->hint(fn ($get) => $get('sDurationError') ? $get('sDurationError') : null)
|
Forms\Components\TextInput::make('name')
|
||||||
->hintColor('danger'),
|
->placeholder('Scan the valid name')
|
||||||
Forms\Components\TimePicker::make('end_time')
|
->autofocus(true)
|
||||||
->required()
|
->required()
|
||||||
->label('End Time')
|
->reactive()
|
||||||
->readOnly()
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
// ->native(false),
|
$nameId = $get('name');
|
||||||
->reactive()
|
$set('start_time', null);
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
if (! $nameId) {
|
||||||
$endTime = $get('end_time');
|
$set('sNameError', 'Scan the valid name.');
|
||||||
$set('end_time', self::calculateEndTime($get('start_time'), $state));
|
|
||||||
if (!$endTime) {
|
return;
|
||||||
$set('sEndTimeError', 'Choose the valid start time & duration.');
|
} else {
|
||||||
return;
|
// $exists = Shift::where('plant_id', $get('plant_id'))
|
||||||
}
|
// ->where('block_id', $get('block_id'))
|
||||||
else
|
// ->where('name', $nameId)
|
||||||
{
|
// ->latest()
|
||||||
$set('sEndTimeError', null);
|
// ->exists();
|
||||||
}
|
// if ($exists)
|
||||||
})
|
// {
|
||||||
->extraAttributes(fn ($get) => [
|
// $set('start_time', null);
|
||||||
'class' => $get('sEndTimeError') ? 'border-red-500' : '',
|
// $set('sNameError', 'Scanned name already exist.');
|
||||||
])
|
// return;
|
||||||
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
|
// }
|
||||||
->hintColor('danger'),
|
$set('sNameError', null);
|
||||||
Forms\Components\TextInput::make('id')
|
}
|
||||||
->hidden()
|
})
|
||||||
->readOnly(),
|
->extraAttributes(fn ($get) => [
|
||||||
])
|
'class' => $get('sNameError') ? 'border-red-500' : '',
|
||||||
->columns(2),
|
])
|
||||||
|
->hint(fn ($get) => $get('sNameError') ? $get('sNameError') : null)
|
||||||
|
->hintColor('danger')
|
||||||
|
->rule(function (callable $get) {
|
||||||
|
return Rule::unique('shifts', 'name')
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->where('block_id', $get('block_id'))
|
||||||
|
->ignore($get('id')); // Ignore current record during updates
|
||||||
|
}),
|
||||||
|
Forms\Components\TimePicker::make('start_time')
|
||||||
|
->required()
|
||||||
|
->label('Start Time')
|
||||||
|
->live()
|
||||||
|
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
||||||
|
// $set('end_time', self::calculateEndTime($state, $get('duration')))
|
||||||
|
// )
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$startTime = $get('start_time');
|
||||||
|
$set('duration', null);
|
||||||
|
$set('end_time', self::calculateEndTime($state, $get('duration')));
|
||||||
|
if (! $startTime) {
|
||||||
|
$set('sStartTimeError', 'Choose the valid start time.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// $exists = Shift::where('plant_id', $get('plant_id'))
|
||||||
|
// ->where('block_id', $get('block_id'))
|
||||||
|
// ->where('name', $get('name'))
|
||||||
|
// ->latest()
|
||||||
|
// ->exists();
|
||||||
|
// if ($exists)
|
||||||
|
// {
|
||||||
|
// $set('start_time', null);
|
||||||
|
// $set('sStartTimeError', null);
|
||||||
|
// $set('sNameError', 'Scanned name already exist.');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
$set('sStartTimeError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('sStartTimeError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('sStartTimeError') ? $get('sStartTimeError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('duration')
|
||||||
|
->required()
|
||||||
|
->placeholder('Scan the valid duration')
|
||||||
|
->numeric()
|
||||||
|
->inputMode('decimal')
|
||||||
|
->minValue(0.01) // Minimum valid duration
|
||||||
|
->lazy()
|
||||||
|
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
||||||
|
// $set('end_time', self::calculateEndTime($get('start_time'), $state))
|
||||||
|
// )
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$duration = $get('duration');
|
||||||
|
// $set('end_time', null);
|
||||||
|
$set('end_time', self::calculateEndTime($get('start_time'), $state));
|
||||||
|
if (! $duration) {
|
||||||
|
$set('sDurationError', 'Scan the valid duration.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
[$hRs, $miNs] = explode('.', $duration) + [0, 0]; // Ensure two parts
|
||||||
|
$hRs = (int) $hRs;
|
||||||
|
$miNs = (int) $miNs;
|
||||||
|
|
||||||
|
$set('duration', $hRs.'.'.$miNs);
|
||||||
|
|
||||||
|
if ($miNs > 60) {
|
||||||
|
$set('sDurationError', 'Minutes exceeds 1 hour.');
|
||||||
|
$set('duration', null);
|
||||||
|
$set('end_time', null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
if ($totalMinutes > 1440) {
|
||||||
|
$set('sDurationError', 'Duration exceeds 24 hours.');
|
||||||
|
$set('duration', null);
|
||||||
|
$set('end_time', null);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$set('sDurationError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('sDurationError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('sDurationError') ? $get('sDurationError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TimePicker::make('end_time')
|
||||||
|
->required()
|
||||||
|
->label('End Time')
|
||||||
|
->readOnly()
|
||||||
|
// ->native(false),
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$endTime = $get('end_time');
|
||||||
|
$set('end_time', self::calculateEndTime($get('start_time'), $state));
|
||||||
|
if (! $endTime) {
|
||||||
|
$set('sEndTimeError', 'Choose the valid start time & duration.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$set('sEndTimeError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('sEndTimeError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +279,7 @@ class ShiftResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
@@ -347,14 +345,14 @@ class ShiftResource extends Resource
|
|||||||
->label('Import Shifts')
|
->label('Import Shifts')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(ShiftImporter::class)
|
->importer(ShiftImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import shift');
|
return Filament::auth()->user()->can('view import shift');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Shifts')
|
->label('Export Shifts')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(ShiftExporter::class)
|
->exporter(ShiftExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export shift');
|
return Filament::auth()->user()->can('view export shift');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
@@ -387,7 +385,7 @@ class ShiftResource extends Resource
|
|||||||
|
|
||||||
protected static function calculateEndTime(?string $startTime, ?string $duration): ?string
|
protected static function calculateEndTime(?string $startTime, ?string $duration): ?string
|
||||||
{
|
{
|
||||||
if (!$startTime || !$duration) {
|
if (! $startTime || ! $duration) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +395,7 @@ class ShiftResource extends Resource
|
|||||||
|
|
||||||
// Ensure duration is in a valid numeric format
|
// Ensure duration is in a valid numeric format
|
||||||
$duration = str_replace(',', '.', $duration); // Handle decimal formats
|
$duration = str_replace(',', '.', $duration); // Handle decimal formats
|
||||||
if (!is_numeric($duration)) {
|
if (! is_numeric($duration)) {
|
||||||
return null; // Invalid duration format
|
return null; // Invalid duration format
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Exports\StickerPrintingExporter;
|
||||||
|
use App\Filament\Imports\StickerPrintingImporter;
|
||||||
use App\Filament\Resources\StickerPrintingResource\Pages;
|
use App\Filament\Resources\StickerPrintingResource\Pages;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\StickerPrinting;
|
use App\Models\StickerPrinting;
|
||||||
@@ -11,14 +13,11 @@ use Filament\Forms\Components\Section;
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use App\Filament\Exports\StickerPrintingExporter;
|
|
||||||
use App\Filament\Imports\StickerPrintingImporter;
|
|
||||||
use Filament\Forms\Components\Actions\Action;
|
|
||||||
|
|
||||||
class StickerPrintingResource extends Resource
|
class StickerPrintingResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -40,13 +39,14 @@ class StickerPrintingResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('reference_number', null);
|
$set('reference_number', null);
|
||||||
$set('serial_number', null);
|
$set('serial_number', null);
|
||||||
$set('ivPlantError', 'Please select a plant first.');
|
$set('ivPlantError', 'Please select a plant first.');
|
||||||
@@ -64,7 +64,7 @@ class StickerPrintingResource extends Resource
|
|||||||
Forms\Components\TextInput::make('reference_number')
|
Forms\Components\TextInput::make('reference_number')
|
||||||
->label('Reference Number')
|
->label('Reference Number')
|
||||||
->reactive()
|
->reactive()
|
||||||
->readOnly(fn (callable $get) => !empty($get('serial_number')))
|
->readOnly(fn (callable $get) => ! empty($get('serial_number')))
|
||||||
->extraAttributes([
|
->extraAttributes([
|
||||||
'id' => 'invoice_number_input',
|
'id' => 'invoice_number_input',
|
||||||
'x-data' => '{ value: "" }',
|
'x-data' => '{ value: "" }',
|
||||||
@@ -82,9 +82,9 @@ class StickerPrintingResource extends Resource
|
|||||||
'x-data' => '{ value: "" }',
|
'x-data' => '{ value: "" }',
|
||||||
'x-model' => 'value',
|
'x-model' => 'value',
|
||||||
'wire:keydown.enter.prevent' => 'processSno(value)',
|
'wire:keydown.enter.prevent' => 'processSno(value)',
|
||||||
//'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
|
// 'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
|
||||||
]),
|
]),
|
||||||
//->required(),
|
// ->required(),
|
||||||
Forms\Components\View::make('forms.components.print-button'),
|
Forms\Components\View::make('forms.components.print-button'),
|
||||||
|
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
|||||||
@@ -5,28 +5,27 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\TempLiveReadingExporter;
|
use App\Filament\Exports\TempLiveReadingExporter;
|
||||||
use App\Filament\Imports\TempLiveReadingImporter;
|
use App\Filament\Imports\TempLiveReadingImporter;
|
||||||
use App\Filament\Resources\TempLiveReadingResource\Pages;
|
use App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||||
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
|
|
||||||
use App\Models\MfmMeter;
|
use App\Models\MfmMeter;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\TempLiveReading;
|
use App\Models\TempLiveReading;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
|
|
||||||
|
|
||||||
class TempLiveReadingResource extends Resource
|
class TempLiveReadingResource extends Resource
|
||||||
{
|
{
|
||||||
protected static ?string $model = TempLiveReading::class;
|
protected static ?string $model = TempLiveReading::class;
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Power House';
|
protected static ?string $navigationGroup = 'Power House';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
@@ -34,37 +33,38 @@ class TempLiveReadingResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
|
||||||
}),
|
|
||||||
Forms\Components\Select::make('mfm_meter_id')
|
|
||||||
->label('MFM Meter ID')
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->options(function (callable $get) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
if (!$plantId) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return MfmMeter::where('plant_id', $plantId)
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
->pluck('sequence', 'id')
|
}),
|
||||||
->toArray();
|
Forms\Components\Select::make('mfm_meter_id')
|
||||||
}),
|
->label('MFM Meter ID')
|
||||||
Forms\Components\TextInput::make('register_data')
|
->required()
|
||||||
->label('Register Data')
|
->reactive()
|
||||||
->required(),
|
->options(function (callable $get) {
|
||||||
Forms\Components\Hidden::make('created_by')
|
$plantId = $get('plant_id');
|
||||||
->default(Filament::auth()->user()?->name),
|
if (! $plantId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return MfmMeter::where('plant_id', $plantId)
|
||||||
|
->pluck('sequence', 'id')
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('register_data')
|
||||||
|
->label('Register Data')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
])
|
])
|
||||||
->columns(3),
|
->columns(3),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +78,7 @@ class TempLiveReadingResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -119,18 +120,18 @@ class TempLiveReadingResource extends Resource
|
|||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
// ->headerActions([
|
// ->headerActions([
|
||||||
// ImportAction::make()
|
// ImportAction::make()
|
||||||
// ->importer(TempLiveReadingImporter::class)
|
// ->importer(TempLiveReadingImporter::class)
|
||||||
// ->visible(function() {
|
// ->visible(function() {
|
||||||
// return Filament::auth()->user()->can('view import temp live reading');
|
// return Filament::auth()->user()->can('view import temp live reading');
|
||||||
// }),
|
// }),
|
||||||
// ExportAction::make()
|
// ExportAction::make()
|
||||||
// ->exporter(TempLiveReadingExporter::class)
|
// ->exporter(TempLiveReadingExporter::class)
|
||||||
// ->visible(function() {
|
// ->visible(function() {
|
||||||
// return Filament::auth()->user()->can('view export temp live reading');
|
// return Filament::auth()->user()->can('view export temp live reading');
|
||||||
// }),
|
// }),
|
||||||
// ]);
|
// ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRelations(): array
|
public static function getRelations(): array
|
||||||
@@ -139,6 +140,7 @@ class TempLiveReadingResource extends Resource
|
|||||||
//
|
//
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNavigationLabel(): string
|
public static function getNavigationLabel(): string
|
||||||
{
|
{
|
||||||
return 'Live Readings';
|
return 'Live Readings';
|
||||||
@@ -149,7 +151,6 @@ class TempLiveReadingResource extends Resource
|
|||||||
return 'Live Readings';
|
return 'Live Readings';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
return optional(TestingPanelReading::latest()->first())->plant_id;
|
return optional(TestingPanelReading::latest()->first())->plant_id;
|
||||||
@@ -480,7 +480,10 @@ class TestingPanelReadingResource extends Resource
|
|||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->nullable()
|
->nullable()
|
||||||
->options(function () {
|
->options(function () {
|
||||||
return Plant::pluck('name', 'id');
|
// return Plant::pluck('name', 'id');
|
||||||
|
$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();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class WeightValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
@@ -168,7 +168,7 @@ class WeightValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive(),
|
->reactive(),
|
||||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
@@ -406,7 +406,7 @@ class WeightValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
->required()
|
->required()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class WorkGroupMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
|
|||||||
Reference in New Issue
Block a user