Adde panel box qr code logic fro production order screen
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
This commit is contained in:
@@ -45,7 +45,8 @@ class ProductionOrderResource extends Resource
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->disabled(fn (string $context): bool => $context == 'edit')
|
||||
->dehydrated(true)
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -84,7 +85,7 @@ class ProductionOrderResource extends Resource
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(ProductionOrder::where('plant_id', $userHas)->latest()->first())->plant_id : optional(ProductionOrder::latest()->first())->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(ProductionOrder::where('plant_id', $userHas)->latest()->first())->item_id : optional(ProductionOrder::latest()->first())->item_id;
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
@@ -102,6 +103,7 @@ class ProductionOrderResource extends Resource
|
||||
->integer()
|
||||
->required()
|
||||
->readOnly(fn ($get) => ($get('plant_id') == null || $get('item_id') == null))
|
||||
->disabled(fn (string $context): bool => $context === 'edit')
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
if (! empty($state) && $state > 0) {
|
||||
$set('show_extra_fields', true);
|
||||
@@ -170,21 +172,39 @@ class ProductionOrderResource extends Resource
|
||||
Forms\Components\Hidden::make('show_extra_fields')
|
||||
->default(false),
|
||||
Forms\Components\DateTimePicker::make('start_date')
|
||||
->label('Start Date'),
|
||||
->label('Start Date')
|
||||
->reactive()
|
||||
// ->minDate(function () {
|
||||
// return Carbon::now()->addMinute();
|
||||
// })
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('end_date', null);
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('end_date')
|
||||
->label('End Date'),
|
||||
->label('End Date')
|
||||
->reactive(),
|
||||
// ->rule('after:start_date')
|
||||
// ->minDate(function (callable $get) {
|
||||
// $startDate = $get('start_date');
|
||||
// if ($startDate) {
|
||||
// return Carbon::parse($startDate)->addMinute();
|
||||
// }
|
||||
|
||||
// return Carbon::now()->addMinute();
|
||||
// }),
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
// ->visible(fn ($get) => $get('show_extra_fields')),
|
||||
Forms\Components\TextInput::make('from_serial_number')
|
||||
->label('From Serial Number')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
Forms\Components\TextInput::make('to_serial_number')
|
||||
->label('To Serial Number')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -209,6 +210,44 @@ class CreateProductionOrder extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
|
||||
@@ -3,13 +3,92 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProductionOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductionOrderResource::class;
|
||||
|
||||
public function printProductionOrder()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.print', ['production_order' => $pOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$plantId = filled($plantId) ? (int) $plantId : null;
|
||||
|
||||
$pOrder = $this->form->getState()['production_order'] ?? null;
|
||||
$pOrder = filled($pOrder) ? trim($pOrder) : null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,13 +3,92 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProductionOrder extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProductionOrderResource::class;
|
||||
|
||||
public function printProductionOrder()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.print', ['production_order' => $pOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$plantId = filled($plantId) ? (int) $plantId : null;
|
||||
|
||||
$pOrder = $this->form->getState()['production_order'] ?? null;
|
||||
$pOrder = filled($pOrder) ? trim($pOrder) : null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user