Updated filter logic, validations and alignments
Some checks are pending
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Some checks are pending
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
This commit is contained in:
@@ -5,16 +5,17 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\RequestCharacteristicExporter;
|
use App\Filament\Exports\RequestCharacteristicExporter;
|
||||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||||
use App\Models\CharacteristicApproverMaster;
|
use App\Models\CharacteristicApproverMaster;
|
||||||
use App\Models\InvoiceValidation;
|
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
use App\Models\StickerMaster;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\Section;
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
use Filament\Forms\Set;
|
use Filament\Forms\Set;
|
||||||
@@ -22,15 +23,12 @@ use Filament\Resources\Resource;
|
|||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
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 Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
|
||||||
use Filament\Forms\Components\Select;
|
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
|
|
||||||
class RequestCharacteristicResource extends Resource
|
class RequestCharacteristicResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -176,6 +174,9 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Forms\Components\TextInput::make('aufnr')
|
Forms\Components\TextInput::make('aufnr')
|
||||||
->label('Job Number')
|
->label('Job Number')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
->numeric()
|
||||||
|
->minlength(7)
|
||||||
|
->maxlength(10)
|
||||||
->required(function (callable $get) {
|
->required(function (callable $get) {
|
||||||
$item = $get('item_id');
|
$item = $get('item_id');
|
||||||
if ($item) {
|
if ($item) {
|
||||||
@@ -876,7 +877,8 @@ class RequestCharacteristicResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('work_flow_id')
|
Tables\Columns\TextColumn::make('work_flow_id')
|
||||||
->label('Work Flow ID')
|
->label('Work Flow ID')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable(), // isIndividual: true
|
->searchable()
|
||||||
|
->sortable(), // isIndividual: true
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant Name')
|
->label('Plant Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -1109,10 +1111,10 @@ class RequestCharacteristicResource extends Resource
|
|||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
$set('machine', null);
|
$set('machine', null);
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('aufnr', null);
|
// $set('aufnr', null);
|
||||||
}),
|
}),
|
||||||
Select::make('machine')
|
Select::make('machine')
|
||||||
->label('Machine')
|
->label('Search by Work Center')
|
||||||
->nullable()
|
->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -1130,8 +1132,8 @@ class RequestCharacteristicResource extends Resource
|
|||||||
})->pluck('work_center', 'id');
|
})->pluck('work_center', 'id');
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
$set('item_id', null);
|
// $set('item_id', null);
|
||||||
$set('aufnr', null);
|
// $set('aufnr', null);
|
||||||
}),
|
}),
|
||||||
Select::make('item_id')
|
Select::make('item_id')
|
||||||
->label('Search by Item Code')
|
->label('Search by Item Code')
|
||||||
@@ -1152,25 +1154,28 @@ class RequestCharacteristicResource extends Resource
|
|||||||
})->pluck('code', 'id');
|
})->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
$set('aufnr', null);
|
// $set('aufnr', null);
|
||||||
}),
|
}),
|
||||||
TextInput::make('aufnr')
|
TextInput::make('aufnr')
|
||||||
->label('Job Number')
|
->label('Job Number')
|
||||||
->placeholder(placeholder: 'Enter Job Number'),
|
->placeholder('Enter Job Number')
|
||||||
|
->numeric()
|
||||||
|
->minlength(7)
|
||||||
|
->maxlength(10),
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
->placeholder(placeholder: 'Select From DateTime')
|
->placeholder('Select From DateTime')
|
||||||
->reactive()
|
->reactive()
|
||||||
->native(false),
|
->native(false),
|
||||||
DateTimePicker::make('created_to')
|
DateTimePicker::make('created_to')
|
||||||
->label('Created To')
|
->label('Created To')
|
||||||
->placeholder(placeholder: 'Select To DateTime')
|
->placeholder('Select To DateTime')
|
||||||
->reactive()
|
->reactive()
|
||||||
->native(false),
|
->native(false),
|
||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if ((empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1218,7 +1223,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['machine'])) {
|
if (! empty($data['machine'])) {
|
||||||
$indicators[] = 'Machine: '.Machine::where('id', $data['machine'])->value('work_center');
|
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['item_id'])) {
|
if (! empty($data['item_id'])) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ClassCharacteristic;
|
||||||
use App\Models\RequestCharacteristic;
|
use App\Models\RequestCharacteristic;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -52,14 +53,13 @@ class CharacteristicApprovalController extends Controller
|
|||||||
foreach ($levels as $lvl => $column) {
|
foreach ($levels as $lvl => $column) {
|
||||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||||
return view('approval.already-processed', [
|
return view('approval.already-processed', [
|
||||||
'status' => $record->$column,
|
'status' => $record->$column,
|
||||||
'message' => 'Your request has already been processed by another approver',
|
'message' => 'Your request has already been processed by another approver',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($levels as $lvl => $column)
|
foreach ($levels as $lvl => $column) {
|
||||||
{
|
|
||||||
if ($record->$column == 'Hold') {
|
if ($record->$column == 'Hold') {
|
||||||
|
|
||||||
if ($lvl == $level) {
|
if ($lvl == $level) {
|
||||||
@@ -127,13 +127,12 @@ class CharacteristicApprovalController extends Controller
|
|||||||
foreach ($levels as $lvl => $column) {
|
foreach ($levels as $lvl => $column) {
|
||||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||||
return view('approval.already-processed', [
|
return view('approval.already-processed', [
|
||||||
'status' => $record->$column,
|
'status' => $record->$column,
|
||||||
'message' => 'Your request has already been processed by another approver',
|
'message' => 'Your request has already been processed by another approver',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// foreach ($levels as $lvl => $column) {
|
// foreach ($levels as $lvl => $column) {
|
||||||
// if ($record->$column == 'Hold') {
|
// if ($record->$column == 'Hold') {
|
||||||
|
|
||||||
@@ -150,7 +149,6 @@ class CharacteristicApprovalController extends Controller
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
$allowedMailStatusByLevel = [
|
$allowedMailStatusByLevel = [
|
||||||
1 => 'Sent',
|
1 => 'Sent',
|
||||||
2 => 'Sent-Mail2',
|
2 => 'Sent-Mail2',
|
||||||
@@ -161,12 +159,11 @@ class CharacteristicApprovalController extends Controller
|
|||||||
|
|
||||||
if ($record->mail_status != $expectedMailStatus) {
|
if ($record->mail_status != $expectedMailStatus) {
|
||||||
return view('approval.approve-level', [
|
return view('approval.approve-level', [
|
||||||
'status'=> $currentStatus,
|
'status' => $currentStatus,
|
||||||
'message' => 'Your approval time limit has expired.',
|
'message' => 'Your approval time limit has expired.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return view('approval.reject-form', compact('id', 'level'));
|
return view('approval.reject-form', compact('id', 'level'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,13 +200,12 @@ class CharacteristicApprovalController extends Controller
|
|||||||
foreach ($levels as $lvl => $column) {
|
foreach ($levels as $lvl => $column) {
|
||||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||||
return view('approval.already-processed', [
|
return view('approval.already-processed', [
|
||||||
'status' => $record->$column,
|
'status' => $record->$column,
|
||||||
'message' => 'Your request has already been processed by another approver',
|
'message' => 'Your request has already been processed by another approver',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// foreach ($levels as $lvl => $column) {
|
// foreach ($levels as $lvl => $column) {
|
||||||
// if ($record->$column == 'Hold') {
|
// if ($record->$column == 'Hold') {
|
||||||
|
|
||||||
@@ -236,7 +232,7 @@ class CharacteristicApprovalController extends Controller
|
|||||||
|
|
||||||
if ($record->mail_status != $expectedMailStatus) {
|
if ($record->mail_status != $expectedMailStatus) {
|
||||||
return view('approval.approve-level', [
|
return view('approval.approve-level', [
|
||||||
'status'=> $currentStatus,
|
'status' => $currentStatus,
|
||||||
'message' => 'Your approval time limit has expired.',
|
'message' => 'Your approval time limit has expired.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -328,7 +324,7 @@ class CharacteristicApprovalController extends Controller
|
|||||||
foreach ($levels as $lvl => $column) {
|
foreach ($levels as $lvl => $column) {
|
||||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||||
return view('approval.already-processed', [
|
return view('approval.already-processed', [
|
||||||
'status' => $record->$column,
|
'status' => $record->$column,
|
||||||
'message' => 'your request has already been processed by another approver',
|
'message' => 'your request has already been processed by another approver',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -345,7 +341,7 @@ class CharacteristicApprovalController extends Controller
|
|||||||
if ($record->mail_status != $expectedMailStatus) {
|
if ($record->mail_status != $expectedMailStatus) {
|
||||||
if ($returnView) {
|
if ($returnView) {
|
||||||
return view('approval.approve-level', [
|
return view('approval.approve-level', [
|
||||||
'status' => $currentStatus,
|
'status' => $currentStatus,
|
||||||
'message' => 'Your approval time limit has expired.',
|
'message' => 'Your approval time limit has expired.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -384,6 +380,12 @@ class CharacteristicApprovalController extends Controller
|
|||||||
$r->update($updateData);
|
$r->update($updateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UPDATE class characteristics
|
||||||
|
// ClassCharacteristic::where('plant_id', $record->plant_id)
|
||||||
|
// ->where('machine_id', $record->machine_id)
|
||||||
|
// ->where('aufnr', $record->aufnr)
|
||||||
|
// ->update(['has_work_flow_id' => $record->work_flow_id]);
|
||||||
|
|
||||||
if ($returnView) {
|
if ($returnView) {
|
||||||
return match ($status) {
|
return match ($status) {
|
||||||
'Approved' => view('approval.success'),
|
'Approved' => view('approval.success'),
|
||||||
|
|||||||
Reference in New Issue
Block a user