17 Commits

Author SHA1 Message Date
dhanabalan
e4223e28be Removed unneccessary arguments in part validation image route
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 25s
Laravel Larastan / larastan (pull_request) Failing after 3m4s
Laravel Pint / pint (pull_request) Successful in 6m24s
2025-12-10 16:50:34 +05:30
dhanabalan
030013f914 changed part validation uploaded image logic in sticker master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 25s
Laravel Pint / pint (pull_request) Successful in 2m52s
Laravel Larastan / larastan (pull_request) Failing after 3m46s
2025-12-10 16:42:41 +05:30
dhanabalan
750f8520f5 Removed image path logic in quality validation resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 2m41s
Laravel Larastan / larastan (pull_request) Failing after 3m12s
2025-12-10 16:41:32 +05:30
dhanabalan
3b0eeda209 changed numeric length in process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 27s
Laravel Larastan / larastan (pull_request) Failing after 3m20s
Laravel Pint / pint (pull_request) Successful in 3m29s
2025-12-10 12:31:48 +05:30
dhanabalan
1bc14aac38 Added numeric length value for column order_quantity and received quantity in process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 22s
Laravel Pint / pint (pull_request) Successful in 2m19s
Laravel Larastan / larastan (pull_request) Failing after 3m26s
2025-12-10 12:27:57 +05:30
dhanabalan
19b44a6705 Added characteristic values post method in chracracteristic controller
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 24s
Laravel Pint / pint (pull_request) Successful in 2m16s
Laravel Larastan / larastan (pull_request) Failing after 3m0s
2025-12-09 17:42:05 +05:30
dhanabalan
364fa1958e Added characteristics values post api in routes
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Gemini PR Review / review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 4m11s
Laravel Larastan / larastan (pull_request) Failing after 4m36s
2025-12-09 17:39:30 +05:30
dhanabalan
587d91d790 Added sub group name in sticker printings
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / review (pull_request) Failing after 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 9s
Laravel Pint / pint (pull_request) Successful in 2m16s
Laravel Larastan / larastan (pull_request) Failing after 3m12s
2025-12-09 17:14:50 +05:30
dhanabalan
00b566a4ca Added sub group name of the product characteristics
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 32s
Laravel Pint / pint (pull_request) Successful in 3m50s
Laravel Larastan / larastan (pull_request) Failing after 4m31s
2025-12-09 17:12:40 +05:30
dhanabalan
a0d715c975 Added characteristic value policy file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / review (pull_request) Failing after 29s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Laravel Pint / pint (pull_request) Successful in 2m30s
Laravel Larastan / larastan (pull_request) Failing after 3m16s
2025-12-09 13:32:03 +05:30
dhanabalan
6c68f2baab Added characteristic value importer and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / review (pull_request) Failing after 34s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Pint / pint (pull_request) Successful in 2m6s
Laravel Larastan / larastan (pull_request) Failing after 3m10s
2025-12-09 13:30:53 +05:30
dhanabalan
27a6b2b5e3 Added characteristic values resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / review (pull_request) Failing after 33s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Pint / pint (pull_request) Successful in 2m23s
Laravel Larastan / larastan (pull_request) Failing after 3m26s
2025-12-09 13:29:42 +05:30
dhanabalan
35d9419198 Added characteristic value model file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / review (pull_request) Failing after 35s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 4m12s
Laravel Larastan / larastan (pull_request) Failing after 5m7s
2025-12-09 13:27:56 +05:30
dhanabalan
63d18fd785 Added characteristics values migration file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 26s
Laravel Pint / pint (pull_request) Successful in 2m11s
Laravel Larastan / larastan (pull_request) Failing after 3m9s
2025-12-09 13:26:57 +05:30
dhanabalan
84b6c45706 removed unwanted serial validation mail logic in invoice validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 34s
Laravel Pint / pint (pull_request) Successful in 2m21s
Laravel Larastan / larastan (pull_request) Failing after 3m22s
2025-12-09 10:50:40 +05:30
dhanabalan
84799678eb changed mail subject for quality validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Gemini PR Review / review (pull_request) Failing after 36s
Laravel Pint / pint (pull_request) Successful in 1m50s
Laravel Larastan / larastan (pull_request) Failing after 2m57s
2025-12-09 08:40:48 +05:30
dhanabalan
db6af9863f Added livewire changes in invoice validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m2s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 42s
Gemini PR Review / review (pull_request) Failing after 1m45s
Laravel Pint / pint (pull_request) Successful in 1m52s
Laravel Larastan / larastan (pull_request) Failing after 3m1s
2025-12-07 14:02:34 +05:30
23 changed files with 1670 additions and 232 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Filament\Exports;
use App\Models\CharacteristicValue;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class CharacteristicValueExporter extends Exporter
{
protected static ?string $model = CharacteristicValue::class;
public static function getColumns(): array
{
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('plant.name'),
ExportColumn::make('line.name'),
ExportColumn::make('item.id'),
ExportColumn::make('machine.name'),
ExportColumn::make('process_order'),
ExportColumn::make('coil_number'),
ExportColumn::make('status'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('created_by'),
ExportColumn::make('updated_by'),
ExportColumn::make('deleted_at'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your characteristic value export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Filament\Imports;
use App\Models\CharacteristicValue;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class CharacteristicValueImporter extends Importer
{
protected static ?string $model = CharacteristicValue::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('machine')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('process_order'),
ImportColumn::make('coil_number'),
ImportColumn::make('status'),
ImportColumn::make('created_by'),
ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?CharacteristicValue
{
// return CharacteristicValue::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new CharacteristicValue();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your characteristic value import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,516 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\CharacteristicValueExporter;
use App\Filament\Imports\CharacteristicValueImporter;
use App\Filament\Resources\CharacteristicValueResource\Pages;
use App\Filament\Resources\CharacteristicValueResource\RelationManagers;
use App\Models\CharacteristicValue;
use App\Models\Item;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Facades\Filament;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
class CharacteristicValueResource extends Resource
{
protected static ?string $model = CharacteristicValue::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Process Order';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->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::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('item_id', null);
$set('line_id', null);
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->extraAttributes(fn ($get) => [
'class' => $get('poPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
->hintColor('danger')
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('item_id', null);
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required(),
Forms\Components\Select::make('item_id')
->label('Item')
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id')) {
return [];
}
return Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('machine_id', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required()
->searchable(),
Forms\Components\Select::make('machine_id')
->label('Machine')
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id') || !$get('item_id')) {
return [];
}
return Machine::where('plant_id', $get('plant_id'))
->where('line_id', $get('line_id'))
->pluck('work_center', 'id')
->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('process_order', null);
$set('coil_number', null);
$set('status', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required(),
Forms\Components\TextInput::make('process_order')
->label('Process Order')
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('coil_number', null);
$set('status', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
})
->required(),
Forms\Components\TextInput::make('coil_number')
->label('Coil Number')
// ->reactive()
// ->afterStateUpdated(function ($state, $set, callable $get) {
// $plantId = $get('plant_id');
// $set('status', null);
// if (! $plantId) {
// $set('poPlantError', 'Please select a plant first.');
// }
// })
// ->required(),
->label('Coil Number')
->default('0')
->reactive()
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$processOrder = $get('process_order');
$coilNo = $get('coil_number');
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
} elseif (! $processOrder) {
$set('coil_number', null);
$set('poPlantError', null);
} elseif ($coilNo || $coilNo == '0') {
$existing = CharacteristicValue::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
$set('poPlantError', null);
$set('coil_number', null);
$set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
} else {
$set('poPlantError', null);
$set('coilNumberError', null);
}
}
})
->extraAttributes(fn ($get) => [
'class' => $get('coilNumberError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('coilNumberError') ? $get('coilNumberError') : null)
->hintColor('danger')
->required(),
Forms\Components\Select::make('status')
->label('Status')
->options([
'Ok' => 'OK',
'NotOk' => 'Not Ok'
])
->reactive()
->required(),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Machine')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('process_order')
->label('Process Order')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('coil_number')
->label('Coil Number')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('status')
->label('Status')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
}),
Select::make('Line')
->label('Select Line')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if(empty($plantId)) {
return [];
}
return Line::where('plant_id', $plantId)->pluck('name', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
}),
Select::make('Item')
->label('Item Code')
->nullable()
->searchable()
->options(function (callable $get) {
$plantId = $get('Plant');
if(empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
Select::make('Machine')
->label('Select Machine')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
$lineId = $get('Line');
if(empty($plantId) || empty($lineId)) {
return [];
}
return Machine::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('work_center', 'id');
//return $plantId ? Item::where('plant_id', $plantId)->pluck('code', 'id') : [];
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('process_order', null);
}),
TextInput::make('process_order')
->label('Process Order')
->placeholder('Enter Process Order'),
TextInput::make('coil_number')
->label('Coil Number')
->placeholder(placeholder: 'Enter Coil Number'),
Select::make('status')
->label('Status')
->options([
'Ok' => 'OK',
'NotOk' => 'Not Ok'
]),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['Machine']) && empty($data['process_order']) && empty($data['coil_number']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['Line'])) {
$query->where('line_id', $data['Line']);
}
if (!empty($data['Item'])) {
$query->where('item_id', $data['Item']);
}
if (!empty($data['Machine'])) {
$query->where('machine_id', $data['Machine']);
}
if (!empty($data['process_order'])) {
$query->where('process_order', $data['process_order']);
}
if (!empty($data['coil_number'])) {
$query->where('coil_number', $data['coil_number']);
}
if (!empty($data['status'])) {
$query->where('status', $data['status']);
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
//$query->orderBy('created_at', 'asc');
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['Line'])) {
$indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name');
}
if (!empty($data['Item'])) {
$indicators[] = 'Item: ' . Item::where('id', $data['Item'])->value('code');
}
if (!empty($data['Machine'])) {
$indicators[] = 'Machine: ' . Machine::where('id', $data['Machine'])->value('work_center');
}
if (!empty($data['process_order'])) {
$indicators[] = 'Process Order: ' . $data['process_order'];
}
if (!empty($data['coil_number'])) {
$indicators[] = 'Coil Number: ' . $data['coil_number'];
}
if (!empty($data['status'])) {
$indicators[] = 'Status: ' . $data['status'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'To: ' . $data['created_to'];
}
return $indicators;
})
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(CharacteristicValueImporter::class)
->label('Import Characteristic Value')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view import characteristic value');
}),
ExportAction::make()
->exporter(CharacteristicValueExporter::class)
->label('Export Characteristic Value')
->color('warning')
->visible(function () {
return Filament::auth()->user()->can('view export characteristic value');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCharacteristicValues::route('/'),
'create' => Pages\CreateCharacteristicValue::route('/create'),
'view' => Pages\ViewCharacteristicValue::route('/{record}'),
'edit' => Pages\EditCharacteristicValue::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -136,23 +136,23 @@ class InvoiceValidationResource extends Resource
->reactive()
->readOnly(fn (callable $get) => empty($get('invoice_number')))
->disabled(fn (Get $get) => empty($get('invoice_number')))
->extraAttributes([
'id' => 'serial_number_input',
'x-data' => '{ value: "" }',
'x-model' => 'value',
'wire:keydown.enter.prevent' => 'processSerial(value)', // Using wire:keydown
])
// ->dehydrated(false) // Do not trigger Livewire syncing
// ->extraAttributes([
// 'id' => 'serial_number_input',
// 'x-on:keydown.enter.prevent' => "
// let serial = \$event.target.value;
// if (serial.trim() != '') {
// \$wire.dispatch('process-scan', serial);
// \$event.target.value = '';
// }
// ",
// 'x-data' => '{ value: "" }',
// 'x-model' => 'value',
// 'wire:keydown.enter.prevent' => 'processSerial(value)', // Using wire:keydown
// ])
->dehydrated(false) // Do not trigger Livewire syncing
->extraAttributes([
'id' => 'serial_number_input',
'x-on:keydown.enter.prevent' => "
let serial = \$event.target.value;
if (serial.trim() != '') {
\$wire.dispatch('process-scan', serial);
\$event.target.value = '';
}
",
])
->afterStateUpdated(function ($state, callable $set, callable $get, callable $livewire) {
$set('update_invoice', 0);
// $this->dispatch('focus-serial-number');

View File

@@ -2261,7 +2261,7 @@ class CreateInvoiceValidation extends CreateRecord
];
}
public function processSerial($serNo)
public function processSer($serNo)
{
$serNo = trim($serNo);
$mSerNo = $serNo;
@@ -3171,9 +3171,11 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice')
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
@@ -3379,18 +3381,18 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
// $mInvoiceType = 'Serial';
// $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
// if (! empty($emails)) {
// Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
// );
// } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
@@ -3509,19 +3511,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
// $mInvoiceType = 'Serial';
// $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
// if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
// );
// } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
@@ -3582,19 +3584,21 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
// $mInvoiceType = 'Serial';
// $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateCapacitorQR')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
// $mUserName = Filament::auth()->user()->name;
// if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'DuplicateCapacitorQR')
// );
// } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$this->form->fill([
'plant_id' => $plantId,
@@ -3719,19 +3723,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
// $mInvoiceType = 'Serial';
// $mailData = $this->getMail();
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
);
} else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
// if (! empty($emails)) {
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
// );
// } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
@@ -3765,11 +3769,11 @@ class CreateInvoiceValidation extends CreateRecord
}
}
// #[On('process-scan')]
// public function processSerial($serial)
// {
// $this->processSer($serial); // Your duplicate check + mail logic
// }
#[On('process-scan')]
public function processSerial($serial)
{
$this->processSer($serial);
}
public function getHeading(): string
{

View File

@@ -27,6 +27,8 @@ class ProductCharacteristicsMasterResource extends Resource
{
protected static ?string $model = ProductCharacteristicsMaster::class;
protected static ?string $navigationGroup = 'Process Order';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form

View File

@@ -6,6 +6,7 @@ use App\Filament\Exports\QualityValidationExporter;
use App\Filament\Imports\QualityValidationImporter;
use App\Filament\Resources\QualityValidationResource\Pages;
use App\Filament\Resources\QualityValidationResource\RelationManagers;
// use App\Jobs\SendInvalidQualityMailJob;
use App\Mail\InvalidQualityMail;
use App\Models\AlertMailRule;
use App\Models\Item;
@@ -13,6 +14,8 @@ use App\Models\Line;
use App\Models\Plant;
use App\Models\QualityValidation;
use App\Models\StickerMaster;
// use App\Models\User;
// use App\Notifications\StatusUpdated;
use Carbon\Carbon;
use Closure;
use Filament\Facades\Filament;
@@ -45,6 +48,7 @@ class QualityValidationResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Display';
public $isSubmitted = false;
public $data = [];
@@ -706,7 +710,6 @@ class QualityValidationResource extends Resource
$fileName = "{$value}.png";
$imageUrl = route('part.validation.image', [
'plant' => $plantCode1,
'filename' => $fileName
]);
@@ -1731,6 +1734,17 @@ class QualityValidationResource extends Resource
$set('tube_sticker_motor_error', null);
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
//$plant = Plant::find($mPlantId);
// $plantCodePart4 = $plant?->code;
// $mlineId = $get('line_id');
// $mLine = Line::find($mlineId);
// $mLinePart = $mLine?->name;
if (empty($state)) {
$set('tube_sticker_motor_error', null);
return;
@@ -1832,6 +1846,24 @@ class QualityValidationResource extends Resource
if (!$isMatch)
{
$set('tube_sticker_motor_error', 'Serial number does not match.');
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerMotor')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
$set('tube_sticker_motor_qr', null);
return;
}
@@ -1856,10 +1888,32 @@ class QualityValidationResource extends Resource
->default('')
->required()
->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) {
$set('tube_sticker_pump_error', null);
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
// $plant = Plant::find($mPlantId);
// $mPlantName = $plant?->name;
// $mlineId = $get('line_id');
// $mLine = Line::find($mlineId);
// $mLinePart = $mLine?->name;
// $mPorder = $get('production_order');
// $mPlantId = $get('plant_id');
// $mlineId = $get('line_id');
// $mUserName = Filament::auth()->user()?->name ?? 'Unknown';
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
//$mUserName = Filament::auth()->user()->name;
if (empty($state)) {
$set('tube_sticker_pump_error', null);
return;
@@ -1941,14 +1995,14 @@ class QualityValidationResource extends Resource
// ]);
$visibleSerialNumber = $get('serial_number');
$expectedItemCode = trim((string) $get('item_id'));
$expectedItemCode = trim((string) $get('item_id'));
if ($itemCode != $expectedItemCode) {
$set('tube_sticker_pump_error', 'Item code does not match.');
return;
}
if ($itemCode != $expectedItemCode) {
$set('tube_sticker_pump_error', 'Item code does not match.');
return;
}
$set('tube_sticker_pump_error', $serialNumber);
$set('tube_sticker_pump_error', $serialNumber);
// $isMatch = in_array($serialNumber, $visibleSerialNumbers, true);
$isMatch = ($visibleSerialNumber == $serialNumber);
@@ -1962,6 +2016,62 @@ class QualityValidationResource extends Resource
{
$set('tube_sticker_pump_error', 'Serial number does not match.');
$set('tube_sticker_pump_qr', null);
// $user = User::where('name', $mUserName)->first();
// if ($user) {
// $user->notify(new StatusUpdated($state));
// }
// $currentUser = Filament::auth()->user();
// if ($currentUser) {
// $currentUser->notify(new StatusUpdated($state)); // standard Laravel DB notification
// // refresh Filament bell
// $livewire->dispatch('refreshFilamentNotifications');
// }
// Notification::make()
// ->title('Status Updated')
// ->body("Serial number scanned: $state")
// ->danger()
// ->sendToDatabase($currentUser);
//$user->notify(new StatusUpdated($state));
//Notification::send($user, new StatusUpdated($state));
//dd($user);
// $user->notify(new StatusUpdated($state));
// Inside a Filament page or resource
//$this->notify('success', "Serial number scanned: $state");
// dispatch(new SendInvalidQualityMailJob(
// $state, $mPorder, $mPlantId, $mlineId, $mUserName, 'InvalidTubeStickerPump'
// ))->afterResponse();
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->queue(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
return;
}
else {
@@ -1989,6 +2099,17 @@ class QualityValidationResource extends Resource
$set('tube_sticker_pumpset_error', null);
$mPorder = $get('production_order');
$mPlantId = $get('plant_id');
//$plant = Plant::find($mPlantId);
// $plantCodePart4 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (empty($state)) {
$set('tube_sticker_pumpset_error', null);
return;
@@ -2092,6 +2213,23 @@ class QualityValidationResource extends Resource
if (!$isMatch)
{
$set('tube_sticker_pumpset_error', 'Serial number does not match.');
// $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
// $mUserName = Filament::auth()->user()->name;
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidTubeStickerPumpset')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
$set('tube_sticker_pumpset_qr', null);
return;
}
@@ -2305,7 +2443,7 @@ class QualityValidationResource extends Resource
$set('part_validation1', null);
$fileName = $expectedValue . ".png"; // or .jpg based on your file
$fullPath = storage_path("app/private/uploads/PartValidation/{$plantCodePart1}/{$fileName}");
$fullPath = storage_path("app/private/uploads/PartValidation/{$fileName}");
// dd($fullPath);
@@ -2316,7 +2454,7 @@ class QualityValidationResource extends Resource
// ]);
if (file_exists($fullPath)) {
$imageUrl = route('part.validation.image', [
'plant' => $plantCodePart1,
// 'plant' => $plantCodePart1,
'filename' => $fileName
]);
} else {
@@ -2607,7 +2745,7 @@ class QualityValidationResource extends Resource
'filename' => $fileName
]);
$set('part_validation2_error_image', $imageUrl);
$set('part_validation4_error_image', $imageUrl);
return;
}
@@ -2771,34 +2909,6 @@ class QualityValidationResource extends Resource
];
}
// public function getMail(){
// //$plantId = $this->form->getState()['plant_id'];
// $plantId = $this->data['plant_id'] ?? null;
// //$this->plantId = $plantId;
// dd($plantId);
// $mInvoiceType = 'Serial';
// $mPlantName = Plant::where('id', $plantId)->value('name');
// $emails = AlertMailRule::where('plant', $plantId)
// //->where('plant', $plantName)
// ->where('module', 'InvoiceValidation')
// ->where('rule_name', 'InvoiceMail')
// ->where(function ($query) {
// $query->whereNull('schedule_type')
// ->orWhere('schedule_type', '');
// })
// ->pluck('email')
// ->toArray();
// return [
// 'plant_id' => $plantId,
// 'plant_name' => $mPlantName,
// 'invoice_type' => $mInvoiceType,
// 'emails' => $emails,
// ];
// }
public static function table(Table $table): Table
{
return $table

View File

@@ -844,50 +844,56 @@ class StickerMasterResource extends Resource
$plantCode = $plant->code;
$sticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->first();
// $sticker = StickerMaster::where('plant_id', $plantId)
// ->where('item_id', $itemId)
// ->first();
if (! $sticker) {
Notification::make()
->title('Unknown Sticker Master')
->body('Sticker Master data not found.')
->danger()
->seconds(2)
->send();
}
// if (! $sticker) {
// Notification::make()
// ->title('Unknown Sticker Master')
// ->body('Sticker Master data not found.')
// ->danger()
// ->seconds(2)
// ->send();
// }
$value = $sticker->{$column};
// $value = $sticker->{$column};
if (empty($value)) {
Notification::make()
->title('Unknown Part validation')
->body("Selected validation '$column' has no value.")
->danger()
->seconds(2)
->send();
}
// if (empty($value)) {
// Notification::make()
// ->title('Unknown Part validation')
// ->body("Selected validation '$column' has no value.")
// ->danger()
// ->seconds(2)
// ->send();
// }
$newFileName = $value.'.png';
// $newFileName = $value.'.png';
$directory = "uploads/PartValidation/{$plantCode}";
$originalName = $uploadedFile->getClientOriginalName();
$directory = 'uploads/PartValidation';
$disk = Storage::disk('local');
if (! $disk->exists($directory)) {
$disk->makeDirectory($directory, 0755, true);
}
// $fullPath = Storage::disk('local')->path($directory);
// $directory = "uploads/PartValidation/{$plantCode}";
// $disk = Storage::disk('local');
// if (! $disk->exists($directory)) {
// $disk->makeDirectory($directory, 0755, true);
// }
// $path = $uploadedFile->storeAs(
// $directory,
// $newFileName,
// 'local'
// );
try {
$path = $uploadedFile->storeAs(
$directory,
$newFileName,
'local'
);
$path = $disk->putFileAs($directory, $uploadedFile, $originalName);
} catch (\Exception $e) {
Notification::make()
->title('Upload Failed')

View File

@@ -26,6 +26,8 @@ class StickerPrintingResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Sticker Reprint';
public static function form(Form $form): Form
{
return $form
@@ -38,7 +40,6 @@ class StickerPrintingResource extends Resource
->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::pluck('name', 'id')->toArray();
})
->required()

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\CharacteristicValue;
use App\Models\ClassCharacteristic;
use App\Models\Item;
use App\Models\Line;
@@ -497,7 +498,7 @@ class CharacteristicsController extends Controller
}
}
$col = ['marked_by', 'man_marked_by'];
$col = ['marked_by', 'man_marked_by', 'motor_marked_by', 'pump_marked_by'];
$missingUsers = [];
$missingUsersPlant = [];
$missingUsersRight = [];
@@ -556,25 +557,148 @@ class CharacteristicsController extends Controller
$isAuto = false;
foreach ($data['characteristics'] as $char) {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'man_marked_status' => $char['man_marked_status'] ?? null,
'man_marked_datetime' => $char['man_marked_datetime'] ?? null,
'man_marked_by' => ($char['man_marked_by'] == 'jothi') ? 'Admin' : $char['man_marked_by'] ?? null,
'motor_marked_status' => $char['motor_marked_status'] ?? null,
'pump_marked_status' => $char['pump_marked_status'] ?? null,
'motor_pump_pumpset_status' => $char['motor_pump_pumpset_status'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
// $values = [
// 'mark_status' => $char['mark_status'] ?? null,
// 'marked_datetime' => $char['marked_datetime'] ?? null,
// 'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
// 'man_marked_status' => $char['man_marked_status'] ?? null,
// 'man_marked_datetime' => $char['man_marked_datetime'] ?? null,
// 'man_marked_by' => ($char['man_marked_by'] == 'jothi') ? 'Admin' : $char['man_marked_by'] ?? null,
// 'motor_marked_status' => $char['motor_marked_status'] ?? null,
// 'pump_marked_status' => $char['pump_marked_status'] ?? null,
// 'motor_pump_pumpset_status' => $char['motor_pump_pumpset_status'] ?? null,
// 'part_validation_1' => $char['part_validation_1'] ?? null,
// 'part_validation_2' => $char['part_validation_2'] ?? null,
// 'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
// 'expected_time' => $char['expected_time'] ?? null,
// 'updated_by' => $userName ?? null,
// ];
if ($jobNo != null && $jobNo != '' && $jobNo) {
$curStat = ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $machineId)
->where('aufnr', $jobNo)
->where('gernr', $serialNumber)
->where('item_id', $itemId)
->first();
if ($char['mark_status'] == 'Stopped') {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'updated_by' => $userName ?? null,
];
} elseif ($char['motor_pump_pumpset_status'] == '3') {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'motor_marked_status' => $char['motor_marked_status'] ?? null,
'motor_marked_by' => ($char['motor_marked_by'] == 'jothi') ? 'Admin' : $char['motor_marked_by'] ?? null,
'pump_marked_status' => $char['pump_marked_status'] ?? null,
'pump_marked_by' => ($char['pump_marked_by'] == 'jothi') ? 'Admin' : $char['pump_marked_by'] ?? null,
'motor_pump_pumpset_status' => '3',
'pumpset_machine_name' => $char['pumpset_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
} elseif ($char['motor_pump_pumpset_status'] == '2') {
if ($curStat->motor_marked_status == null || $curStat->motor_marked_status == '') {
$values = [
// 'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
// 'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'pump_marked_status' => $char['pump_marked_status'] ?? null,
'pump_marked_by' => ($char['pump_marked_by'] == 'jothi') ? 'Admin' : $char['pump_marked_by'] ?? null,
'motor_pump_pumpset_status' => '3',
'pump_machine_name' => $char['pump_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
} else {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'pump_marked_status' => $char['pump_marked_status'] ?? null,
'pump_marked_by' => ($char['pump_marked_by'] == 'jothi') ? 'Admin' : $char['pump_marked_by'] ?? null,
'motor_pump_pumpset_status' => '3',
'pump_machine_name' => $char['pump_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
}
} elseif ($char['motor_pump_pumpset_status'] == '1') {
if ($curStat->pump_marked_status == null || $curStat->pump_marked_status == '') {
$values = [
// 'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
// 'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'motor_marked_status' => $char['motor_marked_status'] ?? null,
'motor_marked_by' => ($char['motor_marked_by'] == 'jothi') ? 'Admin' : $char['motor_marked_by'] ?? null,
'motor_pump_pumpset_status' => '3',
'motor_machine_name' => $char['motor_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
} else {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'motor_marked_status' => $char['motor_marked_status'] ?? null,
'motor_marked_by' => ($char['motor_marked_by'] == 'jothi') ? 'Admin' : $char['motor_marked_by'] ?? null,
'motor_pump_pumpset_status' => '3',
'motor_machine_name' => $char['motor_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
}
} else {
$values = [
'mark_status' => $char['mark_status'] ?? null,
'marked_datetime' => $char['marked_datetime'] ?? null,
'marked_by' => ($char['marked_by'] == 'jothi') ? 'Admin' : $char['marked_by'] ?? null,
'motor_marked_status' => $char['motor_marked_status'] ?? null,
'motor_marked_by' => ($char['motor_marked_by'] == 'jothi') ? 'Admin' : $char['motor_marked_by'] ?? null,
'pump_marked_status' => $char['pump_marked_status'] ?? null,
'pump_marked_by' => ($char['pump_marked_by'] == 'jothi') ? 'Admin' : $char['pump_marked_by'] ?? null,
'motor_pump_pumpset_status' => $char['motor_pump_pumpset_status'] ?? null,
'motor_machine_name' => $char['motor_machine_name'] ?? null,
'pump_machine_name' => $char['pump_machine_name'] ?? null,
'pumpset_machine_name' => $char['pumpset_machine_name'] ?? null,
'part_validation_1' => $char['part_validation_1'] ?? null,
'part_validation_2' => $char['part_validation_2'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
// 'pending_released_status' => $char['pending_released_status'] ?? null,
'expected_time' => $char['expected_time'] ?? null,
'updated_by' => $userName ?? null,
];
}
$isAuto = true;
$affected = ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $machineId)
@@ -585,6 +709,14 @@ class CharacteristicsController extends Controller
$updatedRows += $affected;
} else {
$values = [
'man_marked_status' => $char['man_marked_status'] ?? null,
'man_marked_datetime' => $char['man_marked_datetime'] ?? null,
'man_marked_by' => ($char['man_marked_by'] == 'jothi') ? 'Admin' : $char['man_marked_by'] ?? null,
'samlight_logged_name' => $char['samlight_logged_name'] ?? null,
'updated_by' => $userName ?? null,
];
$isAuto = false;
$affected = ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $machineId)
@@ -1338,7 +1470,7 @@ class CharacteristicsController extends Controller
], 400);
}
$columnsToShow = ['mark_status', 'marked_datetime', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'pump_marked_status', 'motor_pump_pumpset_status', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'expected_time'];
$columnsToShow = ['mark_status', 'marked_datetime', 'marked_by', 'man_marked_status', 'man_marked_datetime', 'man_marked_by', 'motor_marked_status', 'motor_marked_by', 'pump_marked_status', 'pump_marked_by', 'motor_pump_pumpset_status', 'motor_machine_name', 'pump_machine_name', 'pumpset_machine_name', 'part_validation_1', 'part_validation_2', 'samlight_logged_name', 'pending_released_status', 'expected_time'];
$characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name'];
@@ -1391,6 +1523,8 @@ class CharacteristicsController extends Controller
$otherData['marked_by'] = ($otherData['marked_by'] == 'Admin') ? 'jothi' : $otherData['marked_by'] ?? '';
$otherData['man_marked_by'] = ($otherData['man_marked_by'] == 'Admin') ? 'jothi' : $otherData['man_marked_by'] ?? '';
$otherData['motor_marked_by'] = ($otherData['motor_marked_by'] == 'Admin') ? 'jothi' : $otherData['motor_marked_by'] ?? '';
$otherData['pump_marked_by'] = ($otherData['pump_marked_by'] == 'Admin') ? 'jothi' : $otherData['pump_marked_by'] ?? '';
// $otherData['pending_released_status'] = (string)$otherData['pending_released_status'] ?? '';
return array_merge(['gernr' => $serial->gernr], $otherData);
@@ -1520,7 +1654,7 @@ class CharacteristicsController extends Controller
->get();
$remFields = [
'id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_logo_ce', 'zmm_codeclass', 'zmm_colour', 'zmm_logo_cp', 'zmm_grade', 'zmm_grwt_pset', 'zmm_grwt_cable', 'zmm_grwt_motor', 'zmm_grwt_pf', 'zmm_grwt_pump', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_labelperiod', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_modelyear', 'zmm_motoridentification', 'zmm_newt_pset', 'zmm_newt_cable', 'zmm_newt_motor', 'zmm_newt_pf', 'zmm_newt_pump', 'zmm_logo_nsf', 'zmm_packtype', 'zmm_panel', 'zmm_performance_factor', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_eff_ttl', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at',
'id', 'plant_id', 'machine_id', 'item_id', 'gernr', 'zmm_beenote', 'zmm_beenumber', 'zmm_beestar', 'zmm_codeclass', 'zmm_colour', 'zmm_grade', 'zmm_grwt_pset', 'zmm_grwt_cable', 'zmm_grwt_motor', 'zmm_grwt_pf', 'zmm_grwt_pump', 'zmm_isivalve', 'zmm_isi_wc', 'zmm_labelperiod', 'zmm_length', 'zmm_license_cml_no', 'zmm_mfgmonyr', 'zmm_modelyear', 'zmm_motoridentification', 'zmm_newt_pset', 'zmm_newt_cable', 'zmm_newt_motor', 'zmm_newt_pf', 'zmm_newt_pump', 'zmm_packtype', 'zmm_panel', 'zmm_performance_factor', 'zmm_pumpidentification', 'zmm_psettype', 'zmm_size', 'zmm_eff_ttl', 'zmm_type', 'zmm_usp', 'created_at', 'updated_at', 'created_by', 'updated_by', 'deleted_at',
];
$filteredData = $characteristicsData->map(function ($char) use ($remFields) {
@@ -1539,6 +1673,8 @@ class CharacteristicsController extends Controller
$charArray['marked_by'] = ($charArray['marked_by'] == 'Admin') ? 'jothi' : $charArray['marked_by'] ?? '';
$charArray['man_marked_by'] = ($charArray['man_marked_by'] == 'Admin') ? 'jothi' : $charArray['man_marked_by'] ?? '';
$charArray['motor_marked_by'] = ($charArray['motor_marked_by'] == 'Admin') ? 'jothi' : $charArray['motor_marked_by'] ?? '';
$charArray['pump_marked_by'] = ($charArray['pump_marked_by'] == 'Admin') ? 'jothi' : $charArray['pump_marked_by'] ?? '';
foreach ($charArray as $key => $value) {
if ($value instanceof \Carbon\Carbon) {
@@ -1725,7 +1861,7 @@ class CharacteristicsController extends Controller
// $columnsToShow = ['mark_status','marked_datetime','marked_by','man_marked_status','man_marked_datetime','man_marked_by','motor_marked_status','pump_marked_status','motor_pump_pumpset_status','part_validation_1','part_validation_2','samlight_logged_name','pending_released_status','expected_time'];
$characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_laser_name'];
$characteristicsColumns = ['class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_amps', 'zmm_brand', 'zmm_degreeofprotection', 'zmm_delivery', 'zmm_dir_rot', 'zmm_discharge', 'zmm_discharge_max', 'zmm_discharge_min', 'zmm_duty', 'zmm_eff_motor', 'zmm_eff_pump', 'zmm_frequency', 'zmm_head', 'zmm_heading', 'zmm_head_max', 'zmm_head_minimum', 'zmm_idx_eff_mtr', 'zmm_idx_eff_pump', 'zmm_kvacode', 'zmm_maxambtemp', 'zmm_mincoolingflow', 'zmm_motorseries', 'zmm_motor_model', 'zmm_outlet', 'zmm_phase', 'zmm_pressure', 'zmm_pumpflowtype', 'zmm_pumpseries', 'zmm_pump_model', 'zmm_ratedpower', 'zmm_region', 'zmm_servicefactor', 'zmm_servicefactormaximumamps', 'zmm_speed', 'zmm_suction', 'zmm_suctionxdelivery', 'zmm_supplysource', 'zmm_temperature', 'zmm_thrustload', 'zmm_volts', 'zmm_wire', 'zmm_package', 'zmm_pvarrayrating', 'zmm_isi', 'zmm_isimotor', 'zmm_isipump', 'zmm_isipumpset', 'zmm_pumpset_model', 'zmm_stages', 'zmm_headrange', 'zmm_overall_efficiency', 'zmm_connection', 'zmm_min_bore_size', 'zmm_isireference', 'zmm_category', 'zmm_submergence', 'zmm_capacitorstart', 'zmm_capacitorrun', 'zmm_inch', 'zmm_motor_type', 'zmm_dismantle_direction', 'zmm_eff_ovrall', 'zmm_bodymoc', 'zmm_rotormoc', 'zmm_dlwl', 'zmm_inputpower', 'zmm_imp_od', 'zmm_ambtemp', 'zmm_de', 'zmm_dischargerange', 'zmm_efficiency_class', 'zmm_framesize', 'zmm_impellerdiameter', 'zmm_insulationclass', 'zmm_maxflow', 'zmm_minhead', 'zmm_mtrlofconst', 'zmm_nde', 'zmm_powerfactor', 'zmm_tagno', 'zmm_year', 'zmm_logo_cp', 'zmm_logo_ce', 'zmm_logo_nsf', 'zmm_laser_name'];
$characteristicsData = ClassCharacteristic::where('aufnr', $jobNumber)
->where('plant_id', $plantId)
@@ -1976,13 +2112,18 @@ class CharacteristicsController extends Controller
'ZMM_HEADING' => $serialExists->zmm_heading ?? '',
'MARK_STATUS' => $serialExists->mark_status ?? '',
'MARKED_DATETIME' => $serialExists->marked_datetime,
'MARKED_BY' => $serialExists->marked_by ?? '',
'MARKED_BY' => ($serialExists->marked_by == 'Admin') ? 'jothi' : $serialExists->marked_by ?? '',
'MAN_MARKED_STATUS' => $serialExists->man_marked_status ?? '',
'MAN_MARKED_DATETIME' => $serialExists->man_marked_datetime ?? '',
'MAN_MARKED_BY' => $serialExists->man_marked_by ?? '',
'MAN_MARKED_BY' => ($serialExists->man_marked_by == 'Admin') ? 'jothi' : $serialExists->man_marked_by ?? '',
'MOTOR_MARKED_STATUS' => $serialExists->motor_marked_status ?? '',
'MOTOR_MARKED_BY' => ($serialExists->motor_marked_by == 'Admin') ? 'jothi' : $serialExists->motor_marked_by ?? '',
'PUMP_MARKED_STATUS' => $serialExists->pump_marked_status ?? '',
'PUMP_MARKED_BY' => ($serialExists->pump_marked_by == 'Admin') ? 'jothi' : $serialExists->pump_marked_by ?? '',
'MOTOR_PUMP_PUMPSET_STATUS' => $serialExists->motor_pump_pumpset_status ?? '',
'MOTOR_MACHINE_NAME' => $serialExists->motor_machine_name ?? '',
'PUMP_MACHINE_NAME' => $serialExists->pump_machine_name ?? '',
'PUMPSET_MACHINE_NAME' => $serialExists->pumpset_machine_name ?? '',
], 200);
}
}
@@ -2137,6 +2278,221 @@ class CharacteristicsController extends Controller
return response()->json($output, 200);
}
public function storeCharValues(Request $request)
{
$expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW');
$headerAuth = $request->header('Authorization');
$expectedToken = 'Bearer '.$expectedUser.':'.$expectedPw;
if ($headerAuth !== $expectedToken) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!',
], 404);
}
$plantCode = $request->header('plant-code');
$itemCode = $request->header('item-code');
$lineName = $request->header('line-name');
$workCenter = $request->header('work-center');
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code can't be empty!",
], 404);
} elseif (! is_numeric($plantCode) || Str::length($plantCode) < 4 || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) { // !ctype_digit($data['plant_code'])
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid plant code found!',
], 404);
}
$plant = Plant::where('code', $plantCode)->first();
if (! $plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code '{$plantCode}' not found!",
], 404);
}
$plantId = $plant->id;
if ($lineName == null || $lineName == '') {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line name can't be empty!",
], 404);
}
$line = Line::where('name', $lineName)->first();
if (! $line) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line '{$lineName}' not found!",
], 404);
}
$lineAgaPlant = Line::where('plant_id', $plantId)->where('name', $lineName)->first();
if (! $lineAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Line '{$lineName}' not found against plant code '$plantCode'!",
], 404);
}
$lineId = $lineAgaPlant->id;
if ($itemCode == null || $itemCode == '') {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item code can't be empty!",
], 404);
}
$item = Item::where('code', $itemCode)->first();
if (! $item) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code '{$itemCode}' not found!",
], 404);
}
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
if (! $itemAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item code '{$itemCode}' not found against plant code '$plantCode'!",
], 404);
}
$itemId = $itemAgaPlant->id;
if ($workCenter == null || $workCenter == '') {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center can't be empty!",
], 404);
}
$machine = Machine::where('work_center', $workCenter)->first();
if (! $machine) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found!",
], 404);
}
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
if (! $machineAgaPlant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode'!",
], 404);
}
$machineAgaPlantLine = Machine::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_center', $workCenter)->first();
if (! $machineAgaPlantLine) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode' and line name '$lineName'!",
], 404);
}
$machineId = $machineAgaPlantLine->id;
$data = $request->all();
$processOrder = $data['process_order'] ?? '';
$coilNo = $data['coil_number'] ?? '';
$status = $data['status'] ?? '';
$createdBy = $data['created_by'] ?? '';
if ($processOrder == null || $processOrder == '' || ! $processOrder) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Process order can't be empty!",
], 404);
} elseif (Str::length($processOrder) < 9) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Process order should contain minimum 9 digits!',
], 404);
}
if ($coilNo == null || $coilNo == '' || ! $coilNo) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Coil number can't be empty!",
], 404);
} elseif (! is_numeric($coilNo)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Coil number should contain only numeric values!',
], 404);
}
if ($status == null || $status == '' || ! $status) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Status can't be empty!",
], 404);
} elseif (! in_array($status, ['Ok', 'NotOk'], true)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Status must be either 'Ok' or 'NotOk'!",
], 404);
}
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Created by can't be empty!",
], 404);
}
$existing = CharacteristicValue::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', '!=', $itemId)
->first();
if ($existing) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Process order '{$processOrder}' already has item_code '{$existing->item->code}' for the plant code '{$plantCode}'!",
], 404);
}
$existing = CharacteristicValue::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
], 404);
}
CharacteristicValue::create([
'plant_id' => $plantId,
'line_id' => $lineId,
'item_id' => $itemId,
'machine_id' => $machineId,
'process_order' => $processOrder,
'coil_number' => $coilNo,
'status' => $status,
'created_by' => $createdBy,
]);
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => 'Characteristics values inserted successfully',
], 200);
}
/**
* Display the specified resource.
*/

View File

@@ -46,20 +46,20 @@ class InvalidQualityMail extends Mailable
// dynamic subject based on mail type
switch ($this->mailType) {
case 'InvalidPartNumber2':
$this->subjectLine = "Invalid Part Number 2 Scanned ({$this->mplantName})";
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
break;
case 'InvalidPartNumber3':
$this->subjectLine = "Invalid Part Number 3 Scanned ({$this->mplantName})";
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
break;
case 'InvalidPartNumber4':
$this->subjectLine = "Invalid Part Number 4 Scanned ({$this->mplantName})";
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
break;
case 'InvalidPartNumber5':
$this->subjectLine = "Invalid Part Number 5 Scanned ({$this->mplantName})";
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
break;
case 'InvalidPartNumber':
default:
$this->subjectLine = "Invalid Part Number 1 Scanned ({$this->mplantName})";
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
break;
}

View File

@@ -82,12 +82,14 @@ class InvalidSerialMail extends Mailable
public $greeting;
public $subjectLine;
public $mUserName;
public $itemCode;
/**
* Create a new message instance.
*/
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat')
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mUserName, $mailType = 'InvalidFormat')
{
$this->serial = $serial;
$this->invoiceNumber = $invoiceNumber;
@@ -95,6 +97,7 @@ class InvalidSerialMail extends Mailable
$this->mInvoiceType = $mInvoiceType;
$this->mailType = $mailType;
$this->itemCode = $itemCode;
$this->mUserName = $mUserName;
}
/**
@@ -110,15 +113,18 @@ class InvalidSerialMail extends Mailable
case 'DuplicateCapacitorQR':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'CompletedSerialInvoice':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'CSerialInvoice':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'ComSerInv':
case 'InvalidPanelBox':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
// case 'CompletedSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'CSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'ComSerInv':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
}
return new Envelope(
@@ -141,48 +147,20 @@ class InvalidSerialMail extends Mailable
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
";
break;
case 'DuplicateCapacitorQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'CompletedSerialInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'CSerialInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ComSerInv':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
// case 'DuplicateCapacitorQR':
// $this->greeting = "
// Dear Sir/Madam,<br><br>
// The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br>
// <b>Plant:</b> {$this->mplantName}<br>
// <b>Invoice Type:</b> {$this->mInvoiceType}<br>
// <b>Invoice Number:</b> {$this->invoiceNumber}<br>
// <b>Scanned QR Code:</b> {$this->serial}<br>
// <b>Employee Code:</b> {$this->mUserName}<br>
// ";
// break;
}
return new Content(

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class CharacteristicValue extends Model
{
use SoftDeletes;
protected $fillable = [
'plant_id',
'line_id',
'item_id',
'machine_id',
'process_order',
'coil_number',
'status',
'created_at',
'updated_at',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function line(): BelongsTo
{
return $this->belongsTo(Line::class);
}
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
}
}

View File

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

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
CREATE TABLE characteristic_values (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
line_id BIGINT NOT NULL,
item_id BIGINT NOT NULL,
machine_id BIGINT NOT NULL,
process_order TEXT DEFAULT NULL,
coil_number TEXT DEFAULT NULL,
status TEXT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
created_by TEXT DEFAULT NULL,
updated_by TEXT DEFAULT NULL,
deleted_at TIMESTAMP,
FOREIGN KEY (plant_id) REFERENCES plants (id),
FOREIGN KEY (line_id) REFERENCES lines (id),
FOREIGN KEY (item_id) REFERENCES items (id),
FOREIGN KEY (machine_id) REFERENCES machines (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('characteristic_values');
}
};

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// received_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN received_quantity TYPE NUMERIC(10,6)
USING received_quantity::NUMERIC(10,6);
SQL);
// order_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN order_quantity TYPE NUMERIC(10,6)
USING order_quantity::NUMERIC(10,6);
SQL);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN received_quantity TYPE NUMERIC(10,3)
USING received_quantity::NUMERIC(10,3);
SQL);
// order_quantity → NUMERIC(10,6)
DB::statement(<<<SQL
ALTER TABLE process_orders
ALTER COLUMN order_quantity TYPE NUMERIC(10,3)
USING order_quantity::NUMERIC(10,3);
SQL);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('process_orders', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -43,7 +43,6 @@ use Illuminate\Support\Facades\Route;
// return $item;
// });
// Route::post('/user/update', function (Request $request) {
// // Return the request data as JSON
@@ -54,7 +53,6 @@ use Illuminate\Support\Facades\Route;
// ]);
// });
// Route::middleware('auth.basic')->post('/user/update', function (Request $request) {
// return response()->json([
// 'message' => 'Authenticated via Basic Auth',
@@ -63,7 +61,6 @@ use Illuminate\Support\Facades\Route;
// ]);
// });
Route::post('obd/store-data', [ObdController::class, 'store']);
Route::get('obd/get-test-datas', [ObdController::class, 'get_test']);
@@ -78,11 +75,11 @@ Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrP
Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'downloadReprintQrPdf'])->name('download-reprint-qr-pdf');
//Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
// Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
//Production Dashboard Controller
// Production Dashboard Controller
Route::get('get/module-name/data', [ModuleController::class, 'get_module']);
@@ -104,7 +101,7 @@ Route::get('get/module-production-order/data', [ModuleProductionOrderDataControl
Route::get('get/module-production-linestop/data', [ModuleProductionLineStopController::class, 'get_moduleProductionLineStop']);
//Invoice Dashboard Controller
// Invoice Dashboard Controller
Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']);
@@ -114,7 +111,7 @@ Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class,
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
//Guard Dashboard Controller
// Guard Dashboard Controller
Route::get('get/module-guard-day/data', [ModuleGuardDayCountController::class, 'get_guardDay_countData']);
@@ -122,19 +119,19 @@ Route::get('get/module-guard-hourly/data', [ModuleGuardHourlyCountController::cl
Route::get('get/module-guard-name/data', [ModuleGuardNameController::class, 'get_guard_name_Data']);
//Power house controller
// Power house controller
Route::get('get/mfm-parameter/data', [MfmParameterController::class, 'get_mfm_parameter']);
Route::get('get/mfm-parameterid/data', [MfmParameterController::class, 'get_mfm_parameterid']);
//Invoice Validation Controller
// Invoice Validation Controller
Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 'serialInvoice']);
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
//Testing panel Controller
// Testing panel Controller
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']);
@@ -156,25 +153,37 @@ Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
Route::get('sap/files', [SapFileController::class, 'readFiles']);
//..Laser Marking - Characteristics
// ..Laser Marking - Characteristics
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
Route::post('laser/route/data', [CharacteristicsController::class, 'test']);//->withoutMiddleware(VerifyCsrfToken::class)
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
// Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
// //..Part Validation - Characteristics
// Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
// // Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
// Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
// // //..Serial or job
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
// // Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
// // Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
// // //..Job or Master - Characteristics
// // Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
// // //..serial auto or manual
// // Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
// ..Product Characteristics
Route::get('characteristics/get/master', [CharacteristicsController::class, 'getCharMaster']);
//GR Master PDF and Serial Number
Route::post('characteristics/values', [CharacteristicsController::class, 'storeCharValues']);
// GR Master PDF and Serial Number
Route::get('grNumber-pdf', [PdfController::class, 'getGRPdf']);

View File

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
use thiagoalessio\TesseractOCR\TesseractOCR;
use App\Filament\Pages\CustomLogin;
Route::get('/', function () {
return redirect('/admin');
@@ -25,8 +25,8 @@ use App\Filament\Pages\CustomLogin;
]);
});
Route::get('/part-validation-image/{plant}/{filename}', function ($plant, $filename) {
$path = storage_path("app/private/uploads/PartValidation/{$plant}/{$filename}");
Route::get('/part-validation-image/{filename}', function ($filename) {
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
if (!file_exists($path)) {
abort(404, 'Image not found');