Compare commits
105 Commits
a690faf6d7
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7244028d02 | ||
|
|
8104da98d4 | ||
|
|
1d51067355 | ||
|
|
1fd2538048 | ||
|
|
d8fdf02417 | ||
|
|
1031a972de | ||
|
|
f5173d9861 | ||
|
|
9602be624d | ||
|
|
85c7a3e286 | ||
|
|
6071c8b898 | ||
|
|
9bf5337383 | ||
|
|
621cf13565 | ||
|
|
6c334359b2 | ||
|
|
fd444a7749 | ||
|
|
f7a421681e | ||
|
|
8bd64c80d4 | ||
|
|
c4177887d6 | ||
|
|
09772d1984 | ||
|
|
3376d35eaa | ||
|
|
8feb2fc612 | ||
|
|
04d472805f | ||
|
|
f9d2e14210 | ||
|
|
13bef51af5 | ||
|
|
1711ce5646 | ||
|
|
b7da185912 | ||
|
|
4a796a670a | ||
|
|
4577f67d0a | ||
|
|
be2151a072 | ||
|
|
a4251ae532 | ||
|
|
93d55765ae | ||
|
|
17d54cc52e | ||
|
|
61467d88cd | ||
|
|
af0b17e674 | ||
|
|
dd7111a8d9 | ||
|
|
464ee6c3c7 | ||
|
|
984d686182 | ||
|
|
fd87748a38 | ||
|
|
f9aa6cd1ba | ||
|
|
d743b2df26 | ||
|
|
814281a6bf | ||
|
|
dc445b17f5 | ||
|
|
cd553651f3 | ||
|
|
ac20e96358 | ||
|
|
0fb9c91b28 | ||
|
|
21d602d86a | ||
|
|
06628072dc | ||
|
|
cdf9f60ffd | ||
|
|
b419a538dc | ||
|
|
fea15e0d1b | ||
|
|
f5a1e453d5 | ||
|
|
fd6149ccbe | ||
|
|
085a4f72fa | ||
|
|
6b41a27d31 | ||
|
|
648b676453 | ||
|
|
6f4d81025b | ||
|
|
42bbad16aa | ||
|
|
3fcc2de515 | ||
|
|
d14200e40e | ||
|
|
a34322c87a | ||
|
|
547d73e1f4 | ||
|
|
d93d55bb69 | ||
|
|
ad00321dff | ||
|
|
d333324935 | ||
|
|
a1b8cc0eed | ||
|
|
d2a2a35410 | ||
|
|
28503a25c3 | ||
|
|
20b17d446b | ||
|
|
0de50e12b8 | ||
|
|
9767e0547d | ||
|
|
92da8af6d2 | ||
|
|
1adfd59a0e | ||
|
|
92bf1ee401 | ||
|
|
99a605196d | ||
|
|
e075a510d9 | ||
|
|
2a7d012ec8 | ||
|
|
d63e8f7a37 | ||
|
|
9c4679a5a5 | ||
|
|
f6f3ab803c | ||
|
|
64b5c129ee | ||
|
|
955359b92c | ||
|
|
3ffc59f0cf | ||
|
|
9b5e66c834 | ||
|
|
7dbeb0afd3 | ||
|
|
fdfa5d0cf1 | ||
|
|
fce45b5386 | ||
|
|
6a62dce305 | ||
|
|
9ae6dede23 | ||
|
|
2f470c5c54 | ||
|
|
529850f0b9 | ||
|
|
61637bc3d5 | ||
|
|
c248a42a9d | ||
|
|
aeb49c40eb | ||
|
|
8fc963dc0a | ||
|
|
14844f1e1e | ||
|
|
cfc5845768 | ||
|
|
f0a6f924d9 | ||
|
|
f6f9730587 | ||
|
|
b42f5ffe84 | ||
|
|
376899e277 | ||
|
|
e53fb15c01 | ||
|
|
953999459e | ||
|
|
d2ab947b1d | ||
|
|
9b965d5a2b | ||
|
|
f48de19e0d | ||
|
|
48ce416cbf |
62
app/Exports/ProductionPlanExport.php
Normal file
62
app/Exports/ProductionPlanExport.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
|
||||
{
|
||||
|
||||
protected array $data;
|
||||
protected array $dates;
|
||||
|
||||
public function __construct(array $data, array $dates)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->dates = $dates;
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
$headings = [
|
||||
'Plant Name',
|
||||
'Line Name',
|
||||
'Item Code',
|
||||
];
|
||||
|
||||
// Add dynamic headings for each date: Target / Produced
|
||||
foreach ($this->dates as $date) {
|
||||
$headings[] = $date . ' - Target Plan';
|
||||
$headings[] = $date . ' - Produced Quantity';
|
||||
}
|
||||
|
||||
return $headings;
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$mapped = [
|
||||
$row['plant_name'] ?? '',
|
||||
$row['line_name'] ?? '',
|
||||
$row['item_code'] ?? '',
|
||||
];
|
||||
|
||||
// Add daily target and produced quantity for each date
|
||||
foreach ($this->dates as $date) {
|
||||
// $mapped[] = $row['daily_target_dynamic'] ?? 0;
|
||||
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
|
||||
$mapped[] = $row['produced_quantity'][$date] ?? 0;
|
||||
}
|
||||
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
@@ -23,11 +24,33 @@ class ProductionPlanImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('created_at')
|
||||
// ImportColumn::make('created_at')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Created DateTime')
|
||||
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
// ->label('Created DateTime')
|
||||
// ->rules(['required']),
|
||||
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Created DateTime')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000', '1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example(['123456', '210987'])
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plan_quantity')
|
||||
->requiredMapping()
|
||||
@@ -36,175 +59,111 @@ class ProductionPlanImporter extends Importer
|
||||
->label('Plan Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('production_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Quantity')
|
||||
->example(['0', '0'])
|
||||
->label('Production Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name') //ID
|
||||
->example(['Day', 'Night']) //'2', '7'
|
||||
->label('Shift Name') // ID
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('production_quantity')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Production Quantity')
|
||||
// ->example(['0', '0'])
|
||||
// ->label('Production Quantity')
|
||||
// ->numeric()
|
||||
// ->rules(['required', 'integer']),
|
||||
|
||||
// ImportColumn::make('block_reference')
|
||||
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||
// ->exampleHeader('Block Name')
|
||||
// ->example(['Block A', 'Block A'])
|
||||
// ->label('Block Name')
|
||||
// ->rules(['required']), // Or remove if not required
|
||||
// ImportColumn::make('shift')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Shift Name') // ID
|
||||
// ->example(['Day', 'Night']) // '2', '7'
|
||||
// ->label('Shift Name') // ID
|
||||
// ->relationship(resolveUsing: 'name')
|
||||
// ->rules(['required']),
|
||||
|
||||
// ImportColumn::make('updated_at')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Updated DateTime')
|
||||
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
// ->label('Updated DateTime')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('operator_id')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Operator ID')
|
||||
// ->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
// ->label('Operator ID')
|
||||
// ->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionPlan
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$plantCod = $this->data['plant'];
|
||||
$itemCod = $this->data['item'];
|
||||
$plant = null;
|
||||
$line = null;
|
||||
$block = null;
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
}
|
||||
|
||||
if (! $plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (! $line) {
|
||||
$warnMsg[] = "Line not found";
|
||||
$warnMsg[] = 'Line not found';
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
|
||||
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item not found';
|
||||
}
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = "Shift not found";
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
|
||||
|
||||
if(!$itemAgaPlant){
|
||||
$warnMsg[] = 'Item not found against plant code';
|
||||
}
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||
$warnMsg[] = "Invalid plan quantity found";
|
||||
}
|
||||
if (Str::length($this->data['production_quantity']) < 0 || !is_numeric($this->data['production_quantity']) || $this->data['production_quantity'] < 0) {
|
||||
$warnMsg[] = "Invalid production quantity found";
|
||||
}
|
||||
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
$fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else {
|
||||
$fDateOnly = $fdateTime->toDateString();
|
||||
}
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$fromDate) {
|
||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) {
|
||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
$warnMsg[] = 'Invalid plan quantity found';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
} else {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('shift_id', $shift->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereDate('created_at', $fDateOnly)
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionPlan) {
|
||||
// if($productionPlan->production_quantity)
|
||||
// {
|
||||
// throw new RowImportFailedException("{$productionPlan->created_at}, {$productionPlan->production_quantity}");
|
||||
// }
|
||||
// $warnMsg[] = "Production plan already exist on '{$fDateOnly}'!";
|
||||
|
||||
$productionPlan->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
// 'production_quantity' => $productionPlan->production_quantity,
|
||||
// 'created_at' => $productionPlan->created_at,//$fdateTime->format('Y-m-d H:i:s'),
|
||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
$productionPlan->save();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -212,20 +171,15 @@ class ProductionPlanImporter extends Importer
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'shift_id' => $shift->id,
|
||||
'item_id' => $itemAgaPlant->id,
|
||||
// 'shift_id' => $shift->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'production_quantity' => $this->data['production_quantity'],
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
'created_at' =>now(),
|
||||
'updated_at' => now(),
|
||||
'operator_id' => $operatorName,
|
||||
]);
|
||||
return null;
|
||||
// return ProductionPlan::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
// return new ProductionPlan();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
20
app/Filament/Pages/NotificationSettings.php
Normal file
20
app/Filament/Pages/NotificationSettings.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class NotificationSettings extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.notification-settings';
|
||||
|
||||
|
||||
public static function getScripts(): array
|
||||
{
|
||||
return [
|
||||
asset('js/push.js')
|
||||
];
|
||||
}
|
||||
}
|
||||
163
app/Filament/Pages/ProductionCalender.php
Normal file
163
app/Filament/Pages/ProductionCalender.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
|
||||
class ProductionCalender extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-calender';
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected $listeners = ['setWorkingDays'];
|
||||
|
||||
public $pId;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function setWorkingDays($days = null)
|
||||
{
|
||||
$this->form->fill([
|
||||
'working_days' => $days ?? 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
//->options(Plant::pluck('name', 'id'))
|
||||
->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();
|
||||
})
|
||||
->columnSpan(['default' => 10, 'sm' => 7])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('working_days', null);
|
||||
}),
|
||||
TextInput::make('working_days')
|
||||
->label('No. of Working Days')
|
||||
->numeric()
|
||||
->readOnly()
|
||||
->columnSpan(['default' => 10, 'sm' => 2])
|
||||
->required()
|
||||
->minValue(0)
|
||||
->maxValue(31)
|
||||
->placeholder('Enter working days')
|
||||
->id('working_days'),
|
||||
|
||||
Hidden::make('month')
|
||||
->label('Month')
|
||||
->id('month'),
|
||||
|
||||
Hidden::make('year')
|
||||
->label('Year')
|
||||
->id('year'),
|
||||
|
||||
Hidden::make('selected_dates')
|
||||
->label('Selected Dates')
|
||||
->id('selected_dates'),
|
||||
|
||||
ViewField::make('save')
|
||||
->view('forms.save')
|
||||
->columnSpan(['default' => 10, 'sm' => 1]),
|
||||
|
||||
ViewField::make('calendar')
|
||||
->view('forms.calendar')
|
||||
->columnspan(10),
|
||||
])
|
||||
->columns(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveWorkingDays(){
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$workingDays = $this->filters['working_days'] ?? null;
|
||||
$month = $this->filters['month'] ?? null;
|
||||
$year = $this->filters['year'] ?? null;
|
||||
$dates = $this->filters['selected_dates'] ?? null;
|
||||
|
||||
if (!$plantId) {
|
||||
Notification::make()
|
||||
->title('Unknown Plant')
|
||||
->body("Please select a plant first!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$workingDays) {
|
||||
Notification::make()
|
||||
->title('Unknown Working Days')
|
||||
->body("Working days can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$month) {
|
||||
Notification::make()
|
||||
->title('Unknown Month')
|
||||
->body("month can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$year) {
|
||||
Notification::make()
|
||||
->title('Unknown Year')
|
||||
->body("Year can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$updated = ProductionPlan::where('plant_id', $plantId)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->update([
|
||||
'working_days' => $workingDays,
|
||||
'leave_dates' => $dates,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if ($updated) {
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Working days updated successfully!")
|
||||
->success()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No Records Updated')
|
||||
->body("No production plans found for this plant and month.")
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
173
app/Filament/Pages/ProductionTarget.php
Normal file
173
app/Filament/Pages/ProductionTarget.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class ProductionTarget extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-target';
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->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()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$set('line_id', null);
|
||||
$set('year', null);
|
||||
$set('month', null);
|
||||
$this->dispatch('loadData',$state, '', '', '');
|
||||
}),
|
||||
Select::make('line_id')
|
||||
->label('Line')
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('year', null);
|
||||
$set('month', null);
|
||||
$this->dispatch('loadData',$plantId, $state, '', '');
|
||||
}),
|
||||
Select::make('year')
|
||||
->label('Year')
|
||||
->reactive()
|
||||
->options([
|
||||
'2026' => '2026',
|
||||
'2027' => '2027',
|
||||
'2028' => '2028',
|
||||
'2029' => '2029',
|
||||
'2030' => '2030',
|
||||
'2031' => '2031',
|
||||
'2032' => '2032',
|
||||
'2033' => '2033',
|
||||
'2034' => '2034',
|
||||
'2035' => '2035',
|
||||
'2036' => '2036',
|
||||
'2037' => '2037',
|
||||
'2038' => '2038',
|
||||
'2039' => '2039',
|
||||
'2040' => '2040',
|
||||
])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||
$set('month', null);
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
$this->dispatch('loadData',$plantId, $lineId, $state, '');
|
||||
}),
|
||||
|
||||
Select::make('month')
|
||||
->label('Month')
|
||||
->reactive()
|
||||
->options([
|
||||
'01' => 'January',
|
||||
'02' => 'February',
|
||||
'03' => 'March',
|
||||
'04' => 'April',
|
||||
'05' => 'May',
|
||||
'06' => 'June',
|
||||
'07' => 'July',
|
||||
'08' => 'August',
|
||||
'09' => 'September',
|
||||
'10' => 'October',
|
||||
'11' => 'November',
|
||||
'12' => 'December',
|
||||
])
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
// $month = $get('month');
|
||||
$year = $get('year');
|
||||
|
||||
$month = (int) $get('month');
|
||||
|
||||
if (!$month) {
|
||||
return;
|
||||
}
|
||||
$this->dispatch('loadData', $plantId, $lineId, $month, $year);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(4)
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(){
|
||||
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
$lineId = $this->filters['line_id'] ?? null;
|
||||
$year = $this->filters['year'] ?? null;
|
||||
$month = $this->filters['month'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $lineId) {
|
||||
Notification::make()
|
||||
->title('Line')
|
||||
->body("please select line to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $year) {
|
||||
Notification::make()
|
||||
->title('Year')
|
||||
->body("please select year to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (! $month) {
|
||||
Notification::make()
|
||||
->title('Month')
|
||||
->body("please select month to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
|
||||
}
|
||||
}
|
||||
163
app/Filament/Pages/RfqDashboard.php
Normal file
163
app/Filament/Pages/RfqDashboard.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use App\Models\RequestQuotation;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
|
||||
|
||||
class RfqDashboard extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.rfq-dashboard';
|
||||
|
||||
protected static ?string $navigationGroup = 'RFQ Dashboard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['transport_name']);
|
||||
session()->forget(['rfq_number']);
|
||||
$this->filtersForm->fill([
|
||||
'transport_name' => null,
|
||||
'rfq_number' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
// Select::make('plant')
|
||||
// ->label('Select Plant')
|
||||
// ->reactive()
|
||||
// ->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();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['selected_plant' => $state]);
|
||||
// // $set('rfq_number', null);
|
||||
// session()->forget('rfq_number');
|
||||
// }),
|
||||
|
||||
Select::make('rfq_number')
|
||||
->label('Select RFQ Number')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
|
||||
return RequestQuotation::orderBy('rfq_number')
|
||||
->pluck('rfq_number', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['rfq_id' => $state]);
|
||||
$set('transport_name', null);
|
||||
session()->forget('transport_name');
|
||||
}),
|
||||
|
||||
Select::make('transport_name')
|
||||
->label('User name')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$rfqId = $get('rfq_number');
|
||||
|
||||
if (!$rfqId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
if ($user->hasRole(['Super Admin', 'Rfq Supervisor'])) {
|
||||
return RfqTransporterBid::query()
|
||||
->where('request_quotation_id', $rfqId)
|
||||
->whereNotNull('transporter_name')
|
||||
->distinct()
|
||||
->pluck('transporter_name', 'transporter_name')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
return RfqTransporterBid::query()
|
||||
->where('request_quotation_id', $rfqId)
|
||||
->where('transporter_name', $user->name)
|
||||
->distinct()
|
||||
->pluck('transporter_name', 'transporter_name')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['transport_name' => $state]);
|
||||
}),
|
||||
|
||||
// Select::make('transport_name')
|
||||
// ->label('User name')
|
||||
// ->reactive()
|
||||
// ->options(function () {
|
||||
// $user = Filament::auth()->user();
|
||||
|
||||
// if ($user->hasRole(['Super Admin', 'Rfq Supervisor'])) {
|
||||
// return RfqTransporterBid::query()
|
||||
// ->whereNotNull('transporter_name')
|
||||
// ->distinct()
|
||||
// ->pluck('transporter_name', 'transporter_name')
|
||||
// ->toArray();
|
||||
// }
|
||||
|
||||
// return RfqTransporterBid::query()
|
||||
// ->where('transporter_name', $user->name)
|
||||
// ->distinct()
|
||||
// ->pluck('transporter_name', 'transporter_name')
|
||||
// ->toArray();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state, callable $set) {
|
||||
// session(['transport_name' => $state]);
|
||||
// $set('rfq_number', null);
|
||||
// session()->forget('rfq_number');
|
||||
// }),
|
||||
|
||||
// Select::make('rfq_number')
|
||||
// ->label('Select RFQ Number')
|
||||
// ->reactive()
|
||||
// ->options(function (callable $get) {
|
||||
// $transportName = $get('transport_name');
|
||||
|
||||
// if (!$transportName) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// return RequestQuotation::where('transporter_name', $transportName)
|
||||
// ->pluck('rfq_number', 'rfq_number')
|
||||
// ->toArray();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['rfq_number' => $state]);
|
||||
// }),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view rfq dashboard');
|
||||
}
|
||||
}
|
||||
58
app/Filament/Pages/RfqOverview.php
Normal file
58
app/Filament/Pages/RfqOverview.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\RequestQuotation;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RfqOverview extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.rfq-overview';
|
||||
|
||||
protected static ?string $navigationGroup = 'RFQ Dashboard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['rfq_id']);
|
||||
$this->filtersForm->fill([
|
||||
'rfq_id' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('rfq_number')
|
||||
->label('Select RFQ Number')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
return RequestQuotation::orderBy('rfq_number')
|
||||
->pluck('rfq_number', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['rfq_id' => $state]);
|
||||
}),
|
||||
])
|
||||
->columns(1),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view rfq overview dashboard');
|
||||
}
|
||||
}
|
||||
17
app/Filament/Pages/Welcome.php
Normal file
17
app/Filament/Pages/Welcome.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Notifications\PushAlertNotification;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
||||
@@ -136,6 +137,10 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$user1 = Filament::auth()->user();
|
||||
|
||||
$user1->notify(new PushAlertNotification());
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2285,6 +2290,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
|
||||
@@ -82,6 +82,9 @@ class ItemResource extends Resource
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Category')
|
||||
->placeholder('Scan the Category'),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Category')
|
||||
->placeholder('Scan the Category'),
|
||||
Forms\Components\TextInput::make('code')
|
||||
->required()
|
||||
->placeholder('Scan the valid code')
|
||||
|
||||
@@ -5,23 +5,23 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\LineExporter;
|
||||
use App\Filament\Imports\LineImporter;
|
||||
use App\Filament\Resources\LineResource\Pages;
|
||||
use App\Filament\Resources\LineResource\RelationManagers;
|
||||
use App\Models\Block;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Unique;
|
||||
|
||||
@@ -48,7 +48,8 @@ class LineResource extends Resource
|
||||
->reactive()
|
||||
->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();
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Line::latest()->first())->plant_id;
|
||||
@@ -60,10 +61,9 @@ class LineResource extends Resource
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $plantId) {
|
||||
$set('lPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('lPlantError', null);
|
||||
}
|
||||
})
|
||||
@@ -72,6 +72,39 @@ class LineResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('block_id')
|
||||
->label('Block')
|
||||
->relationship('block', 'name')
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Block::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Block::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$blockId = $get('block_id');
|
||||
if (! $blockId) {
|
||||
$set('lblockError', 'Please select a Block first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('lblockError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lblockError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lblockError') ? $get('lblockError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->placeholder('Scan the valid name')
|
||||
@@ -99,10 +132,9 @@ class LineResource extends Resource
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $lineNam) {
|
||||
$set('lNameError', 'Scan the valid name.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// $exists = Line::where('name', $lineNam)
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->exists();
|
||||
@@ -156,6 +188,9 @@ class LineResource extends Resource
|
||||
'Base FG Line' => 'Base FG Line',
|
||||
'SFG Line' => 'SFG Line',
|
||||
'FG Line' => 'FG Line',
|
||||
'Process Base FG Line' => 'Process Base FG Line',
|
||||
'Process SFG Line' => 'Process SFG Line',
|
||||
'Process FG Line' => 'Process FG Line',
|
||||
'Machining Cell' => 'Machining Cell',
|
||||
'Blanking Cell' => 'Blanking Cell',
|
||||
'Forming Cell' => 'Forming Cell',
|
||||
@@ -170,10 +205,9 @@ class LineResource extends Resource
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (! $lineTyp) {
|
||||
$set('lTypeError', 'Scan the valid type.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('lTypeError', null);
|
||||
}
|
||||
})
|
||||
@@ -204,7 +238,7 @@ class LineResource extends Resource
|
||||
|
||||
$partValidDispColumns = [
|
||||
'work_group1_actual_id', 'work_group2_actual_id', 'work_group3_actual_id', 'work_group4_actual_id', 'work_group5_actual_id',
|
||||
'work_group6_actual_id', 'work_group7_actual_id', 'work_group8_actual_id', 'work_group9_actual_id', 'work_group10_actual_id'
|
||||
'work_group6_actual_id', 'work_group7_actual_id', 'work_group8_actual_id', 'work_group9_actual_id', 'work_group10_actual_id',
|
||||
];
|
||||
|
||||
foreach ($partValidDispColumns as $column) {
|
||||
@@ -255,6 +289,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group1_id_error', null);
|
||||
$set('work_group1_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,6 +298,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group1_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -272,6 +308,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group1_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -297,10 +334,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group1_actual_id', '');
|
||||
$set('work_group1_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group1_id_error', null);
|
||||
$set('work_group1_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -332,6 +368,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group2_id_error', null);
|
||||
$set('work_group2_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -340,6 +377,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group2_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,6 +387,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group2_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -369,10 +408,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group2_actual_id', '');
|
||||
$set('work_group2_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group2_id_error', null);
|
||||
$set('work_group2_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -404,6 +442,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group3_id_error', null);
|
||||
$set('work_group3_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -412,6 +451,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group3_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -421,6 +461,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group3_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,10 +482,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group3_actual_id', '');
|
||||
$set('work_group3_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group3_id_error', null);
|
||||
$set('work_group3_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -476,6 +516,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group4_id_error', null);
|
||||
$set('work_group4_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,6 +525,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group4_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -493,6 +535,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group4_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,10 +556,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group4_actual_id', '');
|
||||
$set('work_group4_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group4_id_error', null);
|
||||
$set('work_group4_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -548,6 +590,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group5_id_error', null);
|
||||
$set('work_group5_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -556,6 +599,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group5_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -565,6 +609,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group5_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,10 +630,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group5_actual_id', '');
|
||||
$set('work_group5_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group5_id_error', null);
|
||||
$set('work_group5_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -620,6 +664,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group6_id_error', null);
|
||||
$set('work_group6_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -628,6 +673,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group6_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -637,6 +683,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group6_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -657,10 +704,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group6_actual_id', '');
|
||||
$set('work_group6_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group6_id_error', null);
|
||||
$set('work_group6_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -692,6 +738,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group7_id_error', null);
|
||||
$set('work_group7_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -700,6 +747,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group7_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -709,6 +757,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group7_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -729,10 +778,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group7_actual_id', '');
|
||||
$set('work_group7_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group7_id_error', null);
|
||||
$set('work_group7_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -764,6 +812,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group8_id_error', null);
|
||||
$set('work_group8_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -772,6 +821,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group8_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -781,6 +831,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group8_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -801,10 +852,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group8_actual_id', '');
|
||||
$set('work_group8_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group8_id_error', null);
|
||||
$set('work_group8_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -836,6 +886,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group9_id_error', null);
|
||||
$set('work_group9_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -844,6 +895,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group9_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -853,6 +905,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group9_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -873,10 +926,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group9_actual_id', '');
|
||||
$set('work_group9_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group9_id_error', null);
|
||||
$set('work_group9_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -908,6 +960,7 @@ class LineResource extends Resource
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group10_id_error', null);
|
||||
$set('work_group10_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -916,6 +969,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $plantId) {
|
||||
$set('work_group10_id_error', 'Invalid plant name.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -925,6 +979,7 @@ class LineResource extends Resource
|
||||
|
||||
if (! $workGroupRecord) {
|
||||
$set('work_group10_id_error', 'Work group does not exist for this plant in master.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -945,10 +1000,9 @@ class LineResource extends Resource
|
||||
->send();
|
||||
$set('work_group10_actual_id', '');
|
||||
$set('work_group10_id', null);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('work_group10_id_error', null);
|
||||
$set('work_group10_id', $workGroupRecord->id);
|
||||
}
|
||||
@@ -984,6 +1038,7 @@ class LineResource extends Resource
|
||||
$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')
|
||||
@@ -991,6 +1046,11 @@ class LineResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('block.name')
|
||||
->label('Block')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
|
||||
@@ -6,8 +6,8 @@ use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\ProductionPlanExporter;
|
||||
use App\Filament\Imports\ProductionPlanImporter;
|
||||
use App\Filament\Resources\ProductionPlanResource\Pages;
|
||||
use App\Filament\Resources\ProductionPlanResource\RelationManagers;
|
||||
use App\Models\Block;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
@@ -16,19 +16,18 @@ use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
class ProductionPlanResource extends Resource
|
||||
{
|
||||
@@ -55,7 +54,8 @@ class ProductionPlanResource extends Resource
|
||||
->reactive()
|
||||
->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();
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(ProductionPlan::latest()->first())->plant_id;
|
||||
@@ -67,10 +67,9 @@ class ProductionPlanResource extends Resource
|
||||
$set('block_name', null);
|
||||
if (! $plantId) {
|
||||
$set('ppPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('ppPlantError', null);
|
||||
}
|
||||
})
|
||||
@@ -79,102 +78,6 @@ class ProductionPlanResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('block_name')
|
||||
->required()
|
||||
// ->nullable()
|
||||
->label('Block')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Block::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
|
||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||
})
|
||||
//->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
{
|
||||
$set('block_name', $getBlock->block_id);
|
||||
$set('ppBlockError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$blockId = $get('block_name');
|
||||
$set('shift_id', null);
|
||||
|
||||
if (!$blockId) {
|
||||
$set('ppBlockError', 'Please select a block first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('ppBlockError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('ppBlockError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('ppBlockError') ? $get('ppBlockError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('shift_id')
|
||||
->relationship('shift', 'name')
|
||||
->required()
|
||||
// ->nullable()
|
||||
->autofocus(true)
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('block_name')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Shift::where('plant_id', $get('plant_id'))
|
||||
->where('block_id', $get('block_name'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(ProductionPlan::latest()->first())->shift_id;
|
||||
})
|
||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
if($getShift->shift_id)
|
||||
{
|
||||
$set('shift_id', $getShift->shift_id);
|
||||
$set('ppShiftError', null);
|
||||
}
|
||||
}
|
||||
|
||||
$curShiftId = $get('shift_id');
|
||||
$set('line_id', null);
|
||||
|
||||
if (!$curShiftId) {
|
||||
$set('ppShiftError', 'Please select a shift first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('ppShiftError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('ppShiftError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('ppShiftError') ? $get('ppShiftError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->relationship('line', 'name')
|
||||
->required()
|
||||
@@ -185,7 +88,7 @@ class ProductionPlanResource extends Resource
|
||||
// ->toArray() // Convert collection to array
|
||||
// )
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('block_name') || !$get('shift_id')) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -197,207 +100,81 @@ class ProductionPlanResource extends Resource
|
||||
// ->default(function () {
|
||||
// return optional(ProductionPlan::latest()->first())->line_id;
|
||||
// })
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
if($getShift->line_id)
|
||||
{
|
||||
$set('line_id', $getShift->line_id);
|
||||
$set('ppLineError', null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDT = Carbon::now()->toDateTimeString();
|
||||
$set('created_at', $currentDT);
|
||||
$set('update_date', null);
|
||||
}
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// if ($get('id')) {
|
||||
// $getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||
// if ($getShift->line_id) {
|
||||
// $set('line_id', $getShift->line_id);
|
||||
// $set('ppLineError', null);
|
||||
// }
|
||||
// } else {
|
||||
// $currentDT = Carbon::now()->toDateTimeString();
|
||||
// $set('created_at', $currentDT);
|
||||
// $set('update_date', null);
|
||||
// }
|
||||
|
||||
$lineId = $get('line_id');
|
||||
// $set('plan_quantity', null);
|
||||
// $lineId = $get('line_id');
|
||||
// // $set('plan_quantity', null);
|
||||
|
||||
if (!$lineId) {
|
||||
$set('ppLineError', 'Please select a line first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$isUpdate = !empty($get('id'));
|
||||
if (!$isUpdate)
|
||||
{
|
||||
$exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
->where('shift_id', $get('shift_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->whereDate('created_at', today())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
$set('line_id', null);
|
||||
$set('ppLineError', 'Production plan already updated.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
->where('shift_id', $get('shift_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->whereDate('created_at', Carbon::yesterday())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
if ($existShifts) //if ($existShifts->count() > 0)
|
||||
{
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
$shiftId = Shift::where('id', $get('shift_id'))
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
|
||||
$set('line_id', null);
|
||||
$set('ppLineError', 'Production plan already updated.');
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
$shiftId = Shift::where('id', $get('shift_id'))
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
//echo "Choosed a valid shift...";
|
||||
|
||||
$set('line_id', null);
|
||||
$set('ppLineError', 'Choosed a invalid shift.');
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$set('ppLineError', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
$shiftId = Shift::where('id', $get('shift_id'))
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
|
||||
// here i'm updating created as yesterday
|
||||
$set('created_at', $from_dt);
|
||||
$set('update_date', '1');
|
||||
|
||||
$set('ppLineError', null);
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
$shiftId = Shift::where('id', $get('shift_id'))
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
//echo "Choosed a valid shift...";
|
||||
|
||||
$set('line_id', null);
|
||||
$set('ppLineError', 'Choosed a invalid shift.');
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$set('ppLineError', null);
|
||||
return;
|
||||
}
|
||||
// if (! $lineId) {
|
||||
// $set('ppLineError', 'Please select a line first.');
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// $isUpdate = ! empty($get('id'));
|
||||
// if (! $isUpdate) {
|
||||
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
// //->where('shift_id', $get('shift_id'))
|
||||
// ->where('shift_id', $get('shift_id'))
|
||||
// ->where('line_id', $get('line_id'))
|
||||
// ->whereDate('created_at', today())
|
||||
// ->latest() // Orders by created_at DESC
|
||||
// ->latest()
|
||||
// ->exists();
|
||||
|
||||
// if ($exists) {
|
||||
// $set('line_id', null);
|
||||
// $set('ppLineError', 'Production plan already updated.');
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// $existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
// ->where('shift_id', $get('shift_id'))
|
||||
// ->where('line_id', $get('line_id'))
|
||||
// ->whereDate('created_at', Carbon::yesterday())
|
||||
// ->latest()
|
||||
// ->exists();
|
||||
|
||||
// if ($existShifts) { // if ($existShifts->count() > 0)
|
||||
// // $currentDate = date('Y-m-d');
|
||||
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||
// ->first();
|
||||
|
||||
// if ($exists)
|
||||
// {
|
||||
// $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
// //->where('shift_id', $get('shift_id'))
|
||||
// ->where('line_id', $get('line_id'))
|
||||
// // ->whereDate('created_at', today())
|
||||
// ->whereDate('created_at', today())
|
||||
// ->get();
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
|
||||
// foreach ($existingShifts as $shift) {
|
||||
// $curShiftId = $shift->shift_id;
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// // echo "Choosed a valid shift...";
|
||||
|
||||
// $set('line_id', null);
|
||||
// $set('ppLineError', 'Production plan already updated.');
|
||||
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// } else {
|
||||
// $currentDate = date('Y-m-d');
|
||||
|
||||
// $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
||||
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||
// ->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
@@ -413,32 +190,167 @@ class ProductionPlanResource extends Resource
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
// // echo "Choosed a valid shift...";
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// $set('line_id', null);
|
||||
// $set('ppLineError', 'Production plan already updated.');
|
||||
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// // else {
|
||||
// // $set('ppLineError', 'Choosed a invalid shift...');
|
||||
// }
|
||||
|
||||
// $set('ppLineError', null);
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// // $currentDate = date('Y-m-d');
|
||||
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||
// ->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// // echo "Choosed a valid shift...";
|
||||
|
||||
// // here i'm updating created as yesterday
|
||||
// $set('created_at', $from_dt);
|
||||
// $set('update_date', '1');
|
||||
|
||||
// $set('ppLineError', null);
|
||||
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// } else {
|
||||
// $currentDate = date('Y-m-d');
|
||||
|
||||
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||
// ->first();
|
||||
|
||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// $hRs = (int) $hRs;
|
||||
// // $miNs = (int) $miNs;-*/
|
||||
|
||||
// $totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// $from_dt = $currentDate.' '.$shiftId->start_time;
|
||||
|
||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||
|
||||
// $currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // Check if current date time is within the range
|
||||
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
// // echo "Choosed a valid shift...";
|
||||
|
||||
// $set('line_id', null);
|
||||
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||
|
||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $set('ppLineError', null);
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
// // //->where('shift_id', $get('shift_id'))
|
||||
// // ->where('line_id', $get('line_id'))
|
||||
// // ->whereDate('created_at', today())
|
||||
// // ->latest() // Orders by created_at DESC
|
||||
// // ->first();
|
||||
|
||||
// // if ($exists)
|
||||
// // {
|
||||
// // $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||
// // //->where('shift_id', $get('shift_id'))
|
||||
// // ->where('line_id', $get('line_id'))
|
||||
// // // ->whereDate('created_at', today())
|
||||
// // ->whereDate('created_at', today())
|
||||
// // ->get();
|
||||
|
||||
// // foreach ($existingShifts as $shift) {
|
||||
// // $curShiftId = $shift->shift_id;
|
||||
|
||||
// // $currentDate = date('Y-m-d');
|
||||
|
||||
// // $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
||||
// // ->first();
|
||||
|
||||
// // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
// // $hRs = (int) $hRs;
|
||||
// // // $miNs = (int) $miNs;-*/
|
||||
|
||||
// // $totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
// // $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
// // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
// // $currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// // // Check if current date time is within the range
|
||||
// // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
// // //echo "Choosed a valid shift...";
|
||||
// // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
// // $set('line_id', null);
|
||||
// // $set('ppLineError', 'Production plan already updated.');
|
||||
// // return;
|
||||
// // }
|
||||
// // // else {
|
||||
// // // $set('ppLineError', 'Choosed a invalid shift...');
|
||||
// // // return;
|
||||
// // // }
|
||||
// // }
|
||||
// // $set('ppLineError', null);
|
||||
// // return;
|
||||
// // }
|
||||
// }
|
||||
// $set('ppLineError', null);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
$set('ppLineError', null);
|
||||
}
|
||||
// $set('ppLineError', null);
|
||||
// }
|
||||
// })
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_id', null);
|
||||
$set('plan_quantity', null);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('ppLineError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->required()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('plan_quantity')
|
||||
->required()
|
||||
->integer()
|
||||
@@ -449,10 +361,8 @@ class ProductionPlanResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$planQuan = $get('plan_quantity');
|
||||
|
||||
if(!$get('update_date') )
|
||||
{
|
||||
if(!$get('id'))
|
||||
{
|
||||
if (! $get('update_date')) {
|
||||
if (! $get('id')) {
|
||||
$currentDT = Carbon::now()->toDateTimeString();
|
||||
$set('created_at', $currentDT);
|
||||
}
|
||||
@@ -460,10 +370,9 @@ class ProductionPlanResource extends Resource
|
||||
|
||||
if (! $planQuan) {
|
||||
$set('ppPlanQuanError', 'Scan the valid plan quantity.');
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$set('ppPlanQuanError', null);
|
||||
}
|
||||
})
|
||||
@@ -472,29 +381,19 @@ class ProductionPlanResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('production_quantity')
|
||||
->required()
|
||||
->integer()
|
||||
->label('Production Quantity')
|
||||
->readOnly(fn (callable $get) => !$get('id'))
|
||||
->default(0),
|
||||
// Forms\Components\TextInput::make('production_quantity')
|
||||
// ->required()
|
||||
// ->integer()
|
||||
// ->label('Production Quantity')
|
||||
// ->readOnly(fn (callable $get) => ! $get('id'))
|
||||
// ->default(0),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
Forms\Components\TextInput::make('update_date')
|
||||
->hidden()
|
||||
->reactive()
|
||||
->readOnly(),
|
||||
Forms\Components\DateTimePicker::make('created_at')
|
||||
->label('Created DateTime')
|
||||
->hidden()
|
||||
->reactive()
|
||||
->required()
|
||||
->readOnly(),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
])
|
||||
->columns(2),
|
||||
->columns(4),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -529,34 +428,55 @@ class ProductionPlanResource extends Resource
|
||||
$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')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plan_quantity')
|
||||
->label('Plan Quantity')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('working_days')
|
||||
->label('Working Days')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('production_quantity')
|
||||
->label('Production Quantity')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
->sortable(),// ->searchable(),
|
||||
Tables\Columns\TextColumn::make('shift.block.name')
|
||||
->label('Block')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shift.name')
|
||||
->label('Shift')
|
||||
->alignCenter()
|
||||
->sortable(),// ->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),// ->searchable(),
|
||||
->sortable()
|
||||
->searchable(),
|
||||
// Tables\Columns\TextColumn::make('line.name')
|
||||
// ->label('Line')
|
||||
// ->alignCenter()
|
||||
// ->sortable(), // ->searchable(),
|
||||
// Tables\Columns\TextColumn::make('shift.block.name')
|
||||
// ->label('Block')
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
// Tables\Columns\TextColumn::make('shift.name')
|
||||
// ->label('Shift')
|
||||
// ->alignCenter()
|
||||
// ->sortable(), // ->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
@@ -593,7 +513,8 @@ class ProductionPlanResource extends Resource
|
||||
// })
|
||||
->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();
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -612,6 +533,7 @@ class ProductionPlanResource extends Resource
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
@@ -627,6 +549,7 @@ class ProductionPlanResource extends Resource
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Block::where('plant_id', $get('Plant'))->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
@@ -669,25 +592,33 @@ class ProductionPlanResource extends Resource
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if ($plant = $data['Plant'] ?? null) {
|
||||
$query->where('plant_id', $plant);
|
||||
if (! empty($data['Plant'])) {// if ($plant = $data['Plant'] ?? null) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if ($shift = $data['Shift'] ?? null) {
|
||||
$query->where('shift_id', $shift);
|
||||
if (! empty($data['Shift'])) {// if ($shift = $data['Shift'] ?? null) {
|
||||
$query->where('shift_id', $data['Shift']);
|
||||
}
|
||||
|
||||
if ($line = $data['Line'] ?? null) {
|
||||
$query->where('line_id', $line);
|
||||
|
||||
if (! empty($data['Line'])) {// if ($line = $data['Line'] ?? null) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if ($from = $data['created_from'] ?? null) {
|
||||
$query->where('created_at', '>=', $from);
|
||||
if (! empty($data['created_from'])) {// if ($from = $data['created_from'] ?? null) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if ($to = $data['created_to'] ?? null) {
|
||||
$query->where('created_at', '<=', $to);
|
||||
if (! empty($data['created_to'])) {// if ($to = $data['created_to'] ?? null) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
@@ -695,6 +626,12 @@ class ProductionPlanResource extends Resource
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Shift'])) {
|
||||
@@ -714,7 +651,7 @@ class ProductionPlanResource extends Resource
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
@@ -726,7 +663,7 @@ class ProductionPlanResource extends Resource
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
FilamentExportBulkAction::make('export')
|
||||
FilamentExportBulkAction::make('export'),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
|
||||
295
app/Filament/Resources/RequestQuotationResource.php
Normal file
295
app/Filament/Resources/RequestQuotationResource.php
Normal file
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\RequestQuotationExporter;
|
||||
use App\Filament\Imports\RequestQuotationImporter;
|
||||
use App\Filament\Resources\RequestQuotationResource\Pages;
|
||||
use App\Filament\Resources\RequestQuotationResource\RelationManagers;
|
||||
use App\Models\RequestQuotation;
|
||||
use Filament\Facades\Filament;
|
||||
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 Illuminate\Support\Facades\Auth;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class RequestQuotationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RequestQuotation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Request For Quotation';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
$canEdit = Auth::user()?->can('edit_transport_fields');
|
||||
$canEditData = Auth::user()?->can('edit_all_transport_fields');
|
||||
return $form
|
||||
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('rfq_number')
|
||||
->label('RFQ Number')
|
||||
->readOnly()
|
||||
->required(),
|
||||
Forms\Components\Select::make('spot_rate_transport_master_id')
|
||||
->label('Group Name')
|
||||
->relationship('spotRateTransportMaster', 'group_name')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('rfq_date_time')
|
||||
->label('RFQ Date Time')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('pickup_address')
|
||||
->label('PickUp Address')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('delivery_address')
|
||||
->label('Delivery Address')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('weight')
|
||||
->label('Weight')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('volumetrice_size_inch')
|
||||
->label('Volumetrice')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('type_of_vehicle')
|
||||
->label('Type of Vehicle')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('special_type')
|
||||
->label('Special Type')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('no_of_vehicle')
|
||||
->label('No of Vehicle')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('product_name')
|
||||
->label('Product Name')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('loading_by')
|
||||
->label('Loading By')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('unloading_by')
|
||||
->label('Unloading By')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('pick_and_delivery')
|
||||
->label('Pick and Delivery')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('payment_term')
|
||||
->label('Payment Term')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('paid_topay')
|
||||
->label('Paid Today')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('require_date_time')
|
||||
->label('Require Date Time')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('rfq_rec_on_or_before')
|
||||
->label('RFQ Receive On Or Before')
|
||||
->disabled(fn () => !$canEditData)
|
||||
->required(),
|
||||
// Forms\Components\TextInput::make('transporter_name')
|
||||
// ->label('Transporter Name')
|
||||
// ->disabled(fn () => !($canEdit || $canEditData)),
|
||||
// Forms\Components\TextInput::make('total_freight_charge')
|
||||
// ->label('Total Freight Charge')
|
||||
// ->disabled(fn () => !($canEdit || $canEditData)),
|
||||
// Forms\Components\TextInput::make('transit_day')
|
||||
// ->label('Transit Day')
|
||||
// ->disabled(fn () => !($canEdit || $canEditData)),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By'),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->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('rfq_number')
|
||||
->label('RFQ Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('spotRateTransportMaster.group_name')
|
||||
->label('Group Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rfq_date_time')
|
||||
->label('RFQ Date Time')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pickup_address')
|
||||
->label('PickUp Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('delivery_address')
|
||||
->label('Delivery Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('weight')
|
||||
->label('Weight')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('volumetrice_size_inch')
|
||||
->label('Volumetrice Size Inch')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type_of_vehicle')
|
||||
->label('Type Of Vehicle')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('product_name')
|
||||
->label('Product Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('loading_by')
|
||||
->label('Loading By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('unloading_by')
|
||||
->label('Unloading By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('unloading_by')
|
||||
->label('Unloading By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pick_and_delivery')
|
||||
->label('Pick and Delivery')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('payment_term')
|
||||
->label('Payment Term')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('paid_topay')
|
||||
->label('Paid Today')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('require_date_time')
|
||||
->label('Require Date Time')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rfq_rec_on_or_before')
|
||||
->label('RFQ Receive On Or Before')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transporter_name')
|
||||
->label('Transporter Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('total_freight_charge')
|
||||
->label('Total Freight Charge')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('transit_day')
|
||||
->label('Transit Day')
|
||||
->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(),
|
||||
])
|
||||
->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()
|
||||
->label('Import RequestQuotation')
|
||||
->color('warning')
|
||||
->importer(RequestQuotationImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import request quotation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export RequestQuotation')
|
||||
->color('warning')
|
||||
->exporter(RequestQuotationExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export request quotation');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRequestQuotations::route('/'),
|
||||
'create' => Pages\CreateRequestQuotation::route('/create'),
|
||||
'view' => Pages\ViewRequestQuotation::route('/{record}'),
|
||||
'edit' => Pages\EditRequestQuotation::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestQuotationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestQuotationResource;
|
||||
use App\Models\RequestQuotation;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRequestQuotation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RequestQuotationResource::class;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
parent::mount();
|
||||
|
||||
$this->form->fill([
|
||||
'rfq_number' => $this->generateRfqNumber(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function generateRfqNumber(): string
|
||||
{
|
||||
$year = now()->year;
|
||||
|
||||
$lastRfq = RequestQuotation::whereYear('created_at', $year)
|
||||
->orderBy('id', 'desc')
|
||||
->value('rfq_number');
|
||||
|
||||
if ($lastRfq) {
|
||||
$lastNumber = (int) substr($lastRfq, -3);
|
||||
$nextNumber = str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$nextNumber = '001';
|
||||
}
|
||||
|
||||
return "C.R.I-{$year}-{$nextNumber}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestQuotationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestQuotationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRequestQuotation extends EditRecord
|
||||
{
|
||||
protected static string $resource = RequestQuotationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestQuotationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestQuotationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRequestQuotations extends ListRecords
|
||||
{
|
||||
protected static string $resource = RequestQuotationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestQuotationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestQuotationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewRequestQuotation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RequestQuotationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
345
app/Filament/Resources/RfqTransporterBidResource.php
Normal file
345
app/Filament/Resources/RfqTransporterBidResource.php
Normal file
@@ -0,0 +1,345 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
use App\Filament\Resources\RfqTransporterBidResource\RelationManagers;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
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 Illuminate\Validation\Rule;
|
||||
|
||||
|
||||
class RfqTransporterBidResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RfqTransporterBid::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Request For Quotation';
|
||||
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
])
|
||||
->when(
|
||||
! $user->hasAnyRole(['Super Admin', 'TransporterBidSupervisor']),
|
||||
fn (Builder $query) => $query
|
||||
->where('transporter_name', $user->name)
|
||||
->whereNotNull('request_quotation_id')
|
||||
);
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('request_quotation_id')
|
||||
->label('RFQ Number')
|
||||
// ->relationship('requestQuotation', 'rfq_number')
|
||||
->relationship(
|
||||
'requestQuotation',
|
||||
'rfq_number',
|
||||
function (Builder $query) {
|
||||
|
||||
$userName = Filament::auth()->user()?->name;
|
||||
|
||||
$masterIds = \App\Models\SpotRateTransportMaster::whereRaw(
|
||||
"user_name::jsonb @> ?",
|
||||
[json_encode([$userName])]
|
||||
)
|
||||
->pluck('id')
|
||||
->unique()
|
||||
->toArray();
|
||||
|
||||
if (empty($masterIds)) {
|
||||
$query->whereRaw('1 = 0');
|
||||
return;
|
||||
}
|
||||
|
||||
$query->whereIn('spot_rate_transport_master_id', $masterIds);
|
||||
}
|
||||
)
|
||||
->reactive()
|
||||
// ->disabled(fn ($record) => !Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor']))
|
||||
->disabled(fn ($record) =>
|
||||
!Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor'])
|
||||
&& $record
|
||||
)
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$rfq = \App\Models\RequestQuotation::find($state);
|
||||
if ($rfq) {
|
||||
$set('pickup_address', $rfq->pickup_address);
|
||||
$set('delivery_address', $rfq->delivery_address);
|
||||
$set('type_of_vehicle', $rfq->type_of_vehicle);
|
||||
$set('weight', $rfq->weight);
|
||||
$set('volumetrice_size_inch', $rfq->volumetrice_size_inch);
|
||||
$set('no_of_vehicle', $rfq->no_of_vehicle);
|
||||
$set('product_name', $rfq->product_name);
|
||||
$set('pick_and_delivery', $rfq->pick_and_delivery);
|
||||
$set('payment_term', $rfq->payment_term);
|
||||
$set('paid_topay', $rfq->paid_topay);
|
||||
$set('loading_by', $rfq->loading_by);
|
||||
$set('unloading_by', $rfq->unloading_by);
|
||||
$set('special_type', $rfq->special_type);
|
||||
$set('rfq_date_time', $rfq->rfq_date_time);
|
||||
$set('require_date_time', $rfq->require_date_time);
|
||||
$set('rfq_rec_on_or_before', $rfq->rfq_rec_on_or_before);
|
||||
}
|
||||
})
|
||||
->afterStateHydrated(function ($state, callable $set) {
|
||||
$rfq = \App\Models\RequestQuotation::find($state);
|
||||
if ($rfq) {
|
||||
$set('pickup_address', $rfq->pickup_address);
|
||||
$set('delivery_address', $rfq->delivery_address);
|
||||
$set('type_of_vehicle', $rfq->type_of_vehicle);
|
||||
$set('weight', $rfq->weight);
|
||||
$set('volumetrice_size_inch', $rfq->volumetrice_size_inch);
|
||||
$set('no_of_vehicle', $rfq->no_of_vehicle);
|
||||
$set('product_name', $rfq->product_name);
|
||||
$set('pick_and_delivery', $rfq->pick_and_delivery);
|
||||
$set('payment_term', $rfq->payment_term);
|
||||
$set('paid_topay', $rfq->paid_topay);
|
||||
$set('loading_by', $rfq->loading_by);
|
||||
$set('unloading_by', $rfq->unloading_by);
|
||||
$set('special_type', $rfq->special_type);
|
||||
$set('rfq_date_time', $rfq->rfq_date_time);
|
||||
$set('require_date_time', $rfq->require_date_time);
|
||||
$set('rfq_rec_on_or_before', $rfq->rfq_rec_on_or_before);
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Section::make('RFQ Details')
|
||||
->visible(fn ($get) => $get('request_quotation_id') != null)
|
||||
->reactive()
|
||||
->schema([
|
||||
TextInput::make('pickup_address')->label('Pickup Address')->disabled(),
|
||||
TextInput::make('delivery_address')->label('Delivery Address')->disabled(),
|
||||
TextInput::make('type_of_vehicle')->label('Vehicle Type')->disabled(),
|
||||
TextInput::make('weight')->label('Weight')->disabled(),
|
||||
TextInput::make('volumetrice_size_inch')->label('Volumetric Size')->disabled(),
|
||||
TextInput::make('no_of_vehicle')->label('No. of Vehicle')->disabled(),
|
||||
TextInput::make('product_name')->label('Product Name')->disabled(),
|
||||
TextInput::make('pick_and_delivery')->label('Pick & Delivery')->disabled(),
|
||||
TextInput::make('payment_term')->label('Payment Term')->disabled(),
|
||||
TextInput::make('paid_topay')->label('Paid / To Pay')->disabled(),
|
||||
TextInput::make('loading_by')->label('Loading By')->disabled(),
|
||||
TextInput::make('unloading_by')->label('Unloading By')->disabled(),
|
||||
TextInput::make('special_type')->label('Special Type')->disabled(),
|
||||
TextInput::make('rfq_date_time')->label('RFQ Created On')->disabled(),
|
||||
TextInput::make('require_date_time')->label('Required Date')->disabled(),
|
||||
TextInput::make('rfq_rec_on_or_before')->label('RFQ Received On/Before')->disabled(),
|
||||
]),
|
||||
Forms\Components\TextInput::make('transporter_name')
|
||||
->label('Transporter Name')
|
||||
->readOnly()
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('rfq_transporter_bids', 'transporter_name')
|
||||
->where('request_quotation_id', $get('request_quotation_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('total_freight_charge')
|
||||
->label('Total Freight Charge')
|
||||
->required()
|
||||
// ->disabled(fn ($record) => $record && $record->created_by != Filament::auth()->user()?->name)
|
||||
// ->hidden(fn ($record) => !Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor']) && $record->transporter_name != Filament::auth()->user()?->name),
|
||||
->hidden(fn ($record) =>
|
||||
!Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor'])
|
||||
&& ($record && $record->transporter_name != Filament::auth()->user()?->name) // Ensure $record is not null before checking transporter_name
|
||||
),
|
||||
Forms\Components\TextInput::make('transit_day')
|
||||
->label('Transit Day')
|
||||
->required()
|
||||
// ->disabled(fn ($record) => $record && $record->created_by != Filament::auth()->user()?->name),
|
||||
// ->hidden(fn ($record) => !Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor']) && $record->transporter_name != Filament::auth()->user()?->name),
|
||||
->hidden(fn ($record) =>
|
||||
!Filament::auth()->user()?->hasAnyRole(['Super Admin', 'TransporterBidSupervisor'])
|
||||
&& ($record && $record->transporter_name != Filament::auth()->user()?->name) // Ensure $record is not null before checking transporter_name
|
||||
),
|
||||
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.')
|
||||
->alignCenter()
|
||||
->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('requestQuotation.rfq_number')
|
||||
->label('RFQ Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.pickup_address')
|
||||
->label('PickUp Address')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.delivery_address')
|
||||
->label('Delivery Address')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.type_of_vehicle')
|
||||
->label('Type Of Vehicle')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.weight')
|
||||
->label('Weight')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.volumetrice_size_inch')
|
||||
->label('Volumetrice Size Inch')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.no_of_vehicle')
|
||||
->label('No Of Vehicle')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.product_name')
|
||||
->label('Product Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.pick_and_delivery')
|
||||
->label('Pick And Delivery')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.payment_term')
|
||||
->label('Payment Term')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.paid_topay')
|
||||
->label('Paid Today')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.loading_by')
|
||||
->label('Loading By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.unloading_by')
|
||||
->label('Unloading By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.special_type')
|
||||
->label('Special Type')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.rfq_date_time')
|
||||
->label('RFQ DateTime')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.require_date_time')
|
||||
->label('RFQ Require DateTime')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requestQuotation.rfq_rec_on_or_before')
|
||||
->label('RFQ Rec On Or Before')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRfqTransporterBids::route('/'),
|
||||
'create' => Pages\CreateRfqTransporterBid::route('/create'),
|
||||
'view' => Pages\ViewRfqTransporterBid::route('/{record}'),
|
||||
'edit' => Pages\EditRfqTransporterBid::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
// public static function getEloquentQuery(): Builder
|
||||
// {
|
||||
// return parent::getEloquentQuery()
|
||||
// ->withoutGlobalScopes([
|
||||
// SoftDeletingScope::class,
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use App\Models\User;
|
||||
use App\Notifications\PushAlertNotification;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRfqTransporterBid extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RfqTransporterBidResource::class;
|
||||
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$record = $this->record;
|
||||
|
||||
// Calculate rank based on total_freight_charge
|
||||
$rank = RfqTransporterBid::where('request_quotation_id', $this->record->request_quotation_id)
|
||||
->orderBy('total_freight_charge')
|
||||
->pluck('id')
|
||||
->search($this->record->id) + 1;
|
||||
|
||||
$recipients = User::role(['Super Admin', 'Rfq Supervisor'])->get();
|
||||
$currentUser = Filament::auth()->user();
|
||||
|
||||
|
||||
if ($currentUser && ! $recipients->contains('id', $currentUser->id)) {
|
||||
$recipients->push($currentUser);
|
||||
}
|
||||
|
||||
// $user1 = Filament::auth()->user();
|
||||
|
||||
$rfqNumber = $this->record->requestQuotation->rfq_number;
|
||||
$body = "{$currentUser->name} has updated the bid for RFQ No '{$rfqNumber}'. The current rank is #{$rank}.";
|
||||
|
||||
Notification::make()
|
||||
->title('Rank Updated')
|
||||
->body("{$currentUser->name} has updated the bid for RFQ No '{$rfqNumber}'. The current rank is #{$rank}.")
|
||||
->success()
|
||||
->sendToDatabase($recipients);
|
||||
|
||||
// Push notification
|
||||
foreach ($recipients as $user) {
|
||||
$user->notify(
|
||||
new PushAlertNotification(
|
||||
'New Bid Added',
|
||||
$body
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
\Log::info('Create bid notification sent', [
|
||||
'bid_id' => $record->id,
|
||||
'rank' => $rank,
|
||||
'recipients' => $recipients->pluck('id'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource;
|
||||
use App\Models\RequestQuotation;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use App\Models\User;
|
||||
use App\Notifications\PushAlertNotification;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class EditRfqTransporterBid extends EditRecord
|
||||
{
|
||||
protected static string $resource = RfqTransporterBidResource::class;
|
||||
|
||||
protected function afterSave(): void
|
||||
{
|
||||
if (! $this->record->wasChanged('total_freight_charge')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rank = RfqTransporterBid::where('request_quotation_id', $this->record->request_quotation_id)
|
||||
->orderBy('total_freight_charge')
|
||||
->pluck('id')
|
||||
->search($this->record->id) + 1;
|
||||
|
||||
$requestQuotation = RequestQuotation::findOrFail(
|
||||
$this->record->request_quotation_id
|
||||
);
|
||||
|
||||
$spotRateId = $requestQuotation->spot_rate_transport_master_id;
|
||||
|
||||
$spotRate = SpotRateTransportMaster::findOrFail($spotRateId);
|
||||
|
||||
$userNames = $spotRate->user_name;
|
||||
|
||||
Log::info('User names from spot rate', [
|
||||
'user_name_raw' => $spotRate->user_name,
|
||||
]);
|
||||
|
||||
if (!is_array($userNames)) {
|
||||
Log::warning('user_name is not array, resetting', [
|
||||
'user_name' => $userNames,
|
||||
]);
|
||||
$userNames = [];
|
||||
}
|
||||
|
||||
|
||||
$users = User::whereIn('name', $userNames)->get();
|
||||
|
||||
Log::info('Matched users', [
|
||||
'count' => $users->count(),
|
||||
'user_ids' => $users->pluck('id'),
|
||||
]);
|
||||
|
||||
// $recipients = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->get();
|
||||
|
||||
// $recipients1 = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->whereHas('pushSubscriptions')->get();
|
||||
|
||||
$currentUser = Filament::auth()->user();
|
||||
|
||||
// if ($currentUser && ! $recipients1->contains('id', $currentUser->id)) {
|
||||
// $recipients1->push($currentUser);
|
||||
// }
|
||||
|
||||
// if ($currentUser && ! $recipients->contains('id', $currentUser->id)) {
|
||||
// $recipients->push($currentUser);
|
||||
// }
|
||||
|
||||
// $user1 = Filament::auth()->user();
|
||||
|
||||
|
||||
$rfqNumber = $this->record->requestQuotation->rfq_number;
|
||||
$body = "{$currentUser->name} has updated the bid for RFQ No '{$rfqNumber}'. The current rank is #{$rank}.";
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Rank Updated')
|
||||
// ->body("{$currentUser->name} current rank is #{$rank}")
|
||||
// ->success()
|
||||
// ->sendToDatabase($recipients);
|
||||
|
||||
// \Log::info('Notification sent', [
|
||||
// 'rank' => $rank,
|
||||
// 'recipients' => $recipients->pluck('id'),
|
||||
// ]);
|
||||
|
||||
Notification::make()
|
||||
->title('Rank Updated')
|
||||
->body("{$currentUser->name} has updated the bid for RFQ No '{$rfqNumber}'. The current rank is #{$rank}.")
|
||||
->success()
|
||||
->sendToDatabase($users);
|
||||
|
||||
// foreach ($recipients1 as $user) {
|
||||
// $user->notify(
|
||||
// new PushAlertNotification(
|
||||
// 'Rank Updated',
|
||||
// $body
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
// foreach ($users as $user) {
|
||||
|
||||
// Log::info('Checking push subscription for user', [
|
||||
// 'user_id' => $user->id,
|
||||
// 'name' => $user->name,
|
||||
// 'subscription_count' => $user->pushSubscriptions()->count(),
|
||||
// ]);
|
||||
// if ($user->pushSubscriptions()->exists()) {
|
||||
|
||||
// Log::info('Sending push notification', [
|
||||
// 'user_id' => $user->id,
|
||||
// ]);
|
||||
// $user->notify(
|
||||
// new PushAlertNotification(
|
||||
// 'Rank Updated',
|
||||
// $body
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// else {
|
||||
// Log::warning('User has NO push subscription', [
|
||||
// 'user_id' => $user->id,
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
$count = $user->pushSubscriptions()->count();
|
||||
|
||||
Log::info('Checking push subscription for user', [
|
||||
'user_id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'subscription_count' => $count,
|
||||
]);
|
||||
|
||||
if ($count == 0) {
|
||||
Log::warning('User has NO push subscription', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
Log::info('Sending push notification', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
// ✅ THIS IS ALL YOU NEED
|
||||
$user->notify(new PushAlertNotification(
|
||||
'Rank Updated',
|
||||
$body
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRfqTransporterBids extends ListRecords
|
||||
{
|
||||
protected static string $resource = RfqTransporterBidResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewRfqTransporterBid extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RfqTransporterBidResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
130
app/Filament/Resources/SpotRateTransportMasterResource.php
Normal file
130
app/Filament/Resources/SpotRateTransportMasterResource.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource\RelationManagers;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
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 Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SpotRateTransportMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SpotRateTransportMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Request For Quotation';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('group_name')
|
||||
->label('Group Name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('user_name')
|
||||
->label('User')
|
||||
->multiple()
|
||||
->preload()
|
||||
->reactive()
|
||||
->options(
|
||||
User::pluck('name', 'name')->toArray()
|
||||
)
|
||||
->searchable()
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('id')
|
||||
->label('id'),
|
||||
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('group_name')
|
||||
->label('Group Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('user_name')
|
||||
->label('User Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListSpotRateTransportMasters::route('/'),
|
||||
'create' => Pages\CreateSpotRateTransportMaster::route('/create'),
|
||||
'view' => Pages\ViewSpotRateTransportMaster::route('/{record}'),
|
||||
'edit' => Pages\EditSpotRateTransportMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSpotRateTransportMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SpotRateTransportMasterResource::class;
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
$groupName = $this->data['group_name'] ?? null;
|
||||
$userNames = $this->data['user_name'] ?? [];
|
||||
|
||||
foreach ($userNames as $userName) {
|
||||
|
||||
$query = SpotRateTransportMaster::where('group_name', $groupName)
|
||||
->whereJsonContains('user_name', $userName);
|
||||
|
||||
if ($query->exists()) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate User')
|
||||
->body("User {$userName} already exists in this group.")
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
// Prevent create
|
||||
$this->halt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSpotRateTransportMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = SpotRateTransportMasterResource::class;
|
||||
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$groupName = $this->data['group_name'] ?? null;
|
||||
$userNames = $this->data['user_name'] ?? [];
|
||||
$recordId = $this->record->id ?? null;
|
||||
|
||||
foreach ($userNames as $userName) {
|
||||
|
||||
$query = SpotRateTransportMaster::where('group_name', $groupName)
|
||||
->whereJsonContains('user_name', $userName);
|
||||
|
||||
// Exclude current record for update
|
||||
if ($recordId) {
|
||||
$query->where('id', '!=', $recordId);
|
||||
}
|
||||
|
||||
if ($query->exists()) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate User')
|
||||
->body("User {$userName} already exists in this group.")
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
// Prevent save/update
|
||||
$this->halt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSpotRateTransportMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = SpotRateTransportMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewSpotRateTransportMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = SpotRateTransportMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
146
app/Filament/Widgets/RfqChart.php
Normal file
146
app/Filament/Widgets/RfqChart.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\RequestQuotation;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class RfqChart extends BaseWidget
|
||||
{
|
||||
// protected function getStats(): array
|
||||
// {
|
||||
// $transporter = session('transport_name');
|
||||
// $rfqNumber = session('rfq_number');
|
||||
|
||||
// if (!$transporter || !$rfqNumber) {
|
||||
// return [
|
||||
// Stat::make('Total Freight Charge', '-'),
|
||||
// Stat::make('Rank', '-'),
|
||||
// ];
|
||||
// }
|
||||
|
||||
// $selectedRfq = RequestQuotation::query()
|
||||
// ->where('transporter_name', $transporter)
|
||||
// ->where('rfq_number', $rfqNumber)
|
||||
// ->first();
|
||||
|
||||
// if (!$selectedRfq) {
|
||||
// return [
|
||||
// Stat::make('Total Freight Charge', '-'),
|
||||
// Stat::make('Rank', '-'),
|
||||
// ];
|
||||
// }
|
||||
|
||||
// $myAmount = (float) $selectedRfq->total_freight_charge;
|
||||
|
||||
// $rank = RequestQuotation::query()
|
||||
// ->whereRaw(
|
||||
// 'CAST(total_freight_charge AS DECIMAL(10,2)) < ?',
|
||||
// [$myAmount]
|
||||
// )
|
||||
// ->selectRaw('CAST(total_freight_charge AS DECIMAL(10,2))')
|
||||
// ->distinct()
|
||||
// ->count() + 1;
|
||||
|
||||
// $medal = match (true) {
|
||||
// $rank == 1 => '🥇',
|
||||
// $rank == 2 => '🥈',
|
||||
// $rank == 3 => '🥉',
|
||||
// default => '',
|
||||
// };
|
||||
|
||||
// return [
|
||||
// Stat::make(
|
||||
// 'Total Freight Charge',
|
||||
// number_format($selectedRfq->total_freight_charge, 2)
|
||||
// )
|
||||
// ->description('Transporter: ' . $selectedRfq->transporter_name)
|
||||
// ->color($rank == 1 ? 'success' : 'primary'),
|
||||
|
||||
// Stat::make(
|
||||
// 'Rank',
|
||||
// trim("{$medal} #{$rank}")
|
||||
// )
|
||||
// ->description('Among all transporters')
|
||||
// ->color(
|
||||
// $rank == 1 ? 'success' :
|
||||
// ($rank <= 3 ? 'warning' : 'gray')
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$transporter = session('transport_name');
|
||||
$rfqNumber = session('rfq_id');
|
||||
|
||||
if (!$transporter || !$rfqNumber) {
|
||||
return [
|
||||
Stat::make('Total Freight Charge', '-'),
|
||||
Stat::make('Rank', '-'),
|
||||
];
|
||||
}
|
||||
|
||||
$selectedRfq = RfqTransporterBid::query()
|
||||
->where('transporter_name', $transporter)
|
||||
->where('request_quotation_id', $rfqNumber)
|
||||
->first();
|
||||
|
||||
if (!$selectedRfq) {
|
||||
return [
|
||||
Stat::make('Total Freight Charge', '-'),
|
||||
Stat::make('Rank', '-'),
|
||||
];
|
||||
}
|
||||
|
||||
$myAmount = (float) $selectedRfq->total_freight_charge;
|
||||
|
||||
// $rank = RfqTransporterBid::query()
|
||||
// ->whereRaw(
|
||||
// 'CAST(total_freight_charge AS DECIMAL(10,2)) < ?',
|
||||
// [$myAmount]
|
||||
// )
|
||||
// ->selectRaw('CAST(total_freight_charge AS DECIMAL(10,2))')
|
||||
// ->distinct()
|
||||
// ->count() + 1;
|
||||
$rank = RfqTransporterBid::query()
|
||||
->where('request_quotation_id', $rfqNumber) // 🔥 MISSING CONDITION
|
||||
->whereRaw(
|
||||
'CAST(total_freight_charge AS DECIMAL(10,2)) < ?',
|
||||
[$myAmount]
|
||||
)
|
||||
->selectRaw('CAST(total_freight_charge AS DECIMAL(10,2))')
|
||||
->distinct()
|
||||
->count() + 1;
|
||||
|
||||
|
||||
$medal = match (true) {
|
||||
$rank == 1 => '🥇',
|
||||
$rank == 2 => '🥈',
|
||||
$rank == 3 => '🥉',
|
||||
default => '',
|
||||
};
|
||||
|
||||
return [
|
||||
Stat::make(
|
||||
'Total Freight Charge',
|
||||
number_format($selectedRfq->total_freight_charge, 2)
|
||||
)
|
||||
->description('Transporter: ' . $selectedRfq->transporter_name)
|
||||
->color($rank == 1 ? 'success' : 'primary'),
|
||||
|
||||
Stat::make(
|
||||
'Rank',
|
||||
trim("{$medal} #{$rank}")
|
||||
)
|
||||
->description('Among all transporters')
|
||||
->color(
|
||||
$rank == 1 ? 'success' :
|
||||
($rank <= 3 ? 'warning' : 'gray')
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
205
app/Filament/Widgets/RfqRankChart.php
Normal file
205
app/Filament/Widgets/RfqRankChart.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\RfqTransporterBid;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Js;
|
||||
|
||||
class RfqRankChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Chart';
|
||||
|
||||
// protected function getData(): array
|
||||
// {
|
||||
// $rfqId = session('rfq_id');
|
||||
|
||||
// if (!$rfqId) {
|
||||
// return [
|
||||
// 'datasets' => [],
|
||||
// 'labels' => [],
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // Get bids ordered by lowest freight charge
|
||||
// $bids = RfqTransporterBid::query()
|
||||
// ->where('request_quotation_id', $rfqId)
|
||||
// ->orderByRaw('CAST(total_freight_charge AS DECIMAL(10,2)) ASC')
|
||||
// ->get();
|
||||
|
||||
// // $labels = [];
|
||||
// // $ranks = [];
|
||||
|
||||
// // $rank = 1;
|
||||
// // foreach ($bids as $bid) {
|
||||
// // $labels[] = $bid->transporter_name;
|
||||
// // $ranks[] = $rank++;
|
||||
// // }
|
||||
|
||||
// // return [
|
||||
// // 'datasets' => [
|
||||
// // [
|
||||
// // 'label' => 'Rank (Lower is Better)',
|
||||
// // 'data' => $ranks,
|
||||
// // 'fill' => false,
|
||||
// // 'tension' => 0.3,
|
||||
// // ],
|
||||
// // ],
|
||||
// // 'labels' => $labels,
|
||||
// // ];
|
||||
// $labels = [];
|
||||
// $ranks = [];
|
||||
// $colors = [];
|
||||
|
||||
// $rank = 1;
|
||||
// foreach ($bids as $bid) {
|
||||
// $labels[] = $bid->transporter_name;
|
||||
// $ranks[] = $rank;
|
||||
|
||||
// // Rank-based colors
|
||||
// $colors[] = match ($rank) {
|
||||
// 1 => '#FFD700', // Gold
|
||||
// 2 => '#C0C0C0', // Silver
|
||||
// 3 => '#CD7F32', // Bronze
|
||||
// default => '#3B82F6', // Blue
|
||||
// };
|
||||
|
||||
// $rank++;
|
||||
// }
|
||||
|
||||
// return [
|
||||
// 'datasets' => [
|
||||
// [
|
||||
// 'label' => 'Rank (1 = Best)',
|
||||
// 'data' => $ranks,
|
||||
|
||||
// // 🎨 Styling
|
||||
// 'borderColor' => '#3B82F6',
|
||||
// 'backgroundColor' => $colors,
|
||||
// 'pointBackgroundColor' => $colors,
|
||||
// 'pointBorderColor' => '#000',
|
||||
// 'pointRadius' => 7,
|
||||
// 'pointHoverRadius' => 10,
|
||||
// 'borderWidth' => 3,
|
||||
// 'tension' => 0.4,
|
||||
// 'fill' => false,
|
||||
// ],
|
||||
// ],
|
||||
// 'labels' => $labels,
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$rfqId = session('rfq_id');
|
||||
|
||||
if (!$rfqId) {
|
||||
return [
|
||||
'datasets' => [],
|
||||
'labels' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* STEP 1: Get bids sorted by freight charge (for ranking)
|
||||
*/
|
||||
$rankedBids = RfqTransporterBid::query()
|
||||
->where('request_quotation_id', $rfqId)
|
||||
->orderByRaw('CAST(total_freight_charge AS DECIMAL(10,2)) ASC')
|
||||
->get();
|
||||
|
||||
$rankMap = [];
|
||||
$rank = 1;
|
||||
|
||||
foreach ($rankedBids as $bid) {
|
||||
$rankMap[$bid->id] = $rank++;
|
||||
}
|
||||
|
||||
/**
|
||||
* STEP 2: Get bids in natural order (for wave effect)
|
||||
* You can change orderBy to:
|
||||
* - created_at
|
||||
* - transporter_name
|
||||
*/
|
||||
$chartBids = RfqTransporterBid::query()
|
||||
->where('request_quotation_id', $rfqId)
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
$labels = [];
|
||||
$amounts = [];
|
||||
$colors = [];
|
||||
|
||||
$ranks = [];
|
||||
|
||||
foreach ($chartBids as $bid) {
|
||||
$labels[] = $bid->transporter_name;
|
||||
$amounts[] = (float) $bid->total_freight_charge;
|
||||
|
||||
$rank = $rankMap[$bid->id];
|
||||
$ranks[] = $rank;
|
||||
|
||||
$colors[] = match ($rank) {
|
||||
1 => '#FFD700',
|
||||
2 => '#C0C0C0',
|
||||
3 => '#CD7F32',
|
||||
default => '#2563EB',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Freight Charge',
|
||||
'data' => $amounts,
|
||||
'rankData' => $ranks,
|
||||
|
||||
'borderColor' => '#2563EB',
|
||||
'backgroundColor' => $colors,
|
||||
'pointBackgroundColor' => $colors,
|
||||
'pointBorderColor' => '#000',
|
||||
'pointRadius' => 7,
|
||||
'pointHoverRadius' => 11,
|
||||
'borderWidth' => 3,
|
||||
'tension' => 0.45,
|
||||
'fill' => false,
|
||||
],
|
||||
],
|
||||
'labels' => $labels,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'plugins' => [
|
||||
'datalabels' => [
|
||||
'anchor' => 'start',
|
||||
'align' => 'start',
|
||||
'offset' => -15,
|
||||
'color' => '#000',
|
||||
'font' => [
|
||||
'weight' => 'bold',
|
||||
],
|
||||
'formatter' => Js::from("function(value) { return Number(value); }"),
|
||||
],
|
||||
],
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true,
|
||||
'ticks' => [
|
||||
'stepSize' => 0.5,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
236
app/Livewire/ProductionTargetPlan.php
Normal file
236
app/Livewire/ProductionTargetPlan.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Exports\ProductionPlanExport;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Livewire\Component;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ProductionTargetPlan extends Component
|
||||
{
|
||||
|
||||
public $plantId, $lineId, $month, $year;
|
||||
|
||||
public $records = [];
|
||||
|
||||
public $dates = [];
|
||||
|
||||
public $leaveDates = [];
|
||||
|
||||
public $productionPlanDates = '';
|
||||
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadProductionData',
|
||||
'loadData1' => 'exportProductionData',
|
||||
];
|
||||
|
||||
public function getMonthDates($month, $year)
|
||||
{
|
||||
$start = Carbon::createFromDate($year, $month, 1);
|
||||
$days = $start->daysInMonth;
|
||||
|
||||
$dates = [];
|
||||
|
||||
for ($i = 1; $i <= $days; $i++) {
|
||||
$dates[] = Carbon::createFromDate($year, $month, $i)
|
||||
->format('Y-m-d');
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
public function loadProductionData($plantId, $lineId, $month, $year){
|
||||
|
||||
if (!$plantId || !$lineId || !$month || !$year) {
|
||||
$this->records = [];
|
||||
$this->dates = [];
|
||||
$this->leaveDates = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dates = $this->getMonthDates($month, $year);
|
||||
|
||||
$data = ProductionPlan::query()
|
||||
->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||
->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||
->where('production_plans.plant_id', $plantId)
|
||||
->where('production_plans.line_id', $lineId)
|
||||
->whereMonth('production_plans.created_at', $month)
|
||||
->whereYear('production_plans.created_at', $year)
|
||||
->select(
|
||||
'production_plans.created_at',
|
||||
'production_plans.operator_id',
|
||||
'plants.name as plant',
|
||||
'items.code as item_code',
|
||||
'items.description as item_description',
|
||||
'lines.name as line_name',
|
||||
'production_plans.leave_dates'
|
||||
)
|
||||
->first();
|
||||
|
||||
if ($data && $data->leave_dates) {
|
||||
$this->leaveDates = array_map('trim', explode(',', $data->leave_dates));
|
||||
}
|
||||
|
||||
$producedData = ProductionQuantity::selectRaw("
|
||||
plant_id,
|
||||
line_id,
|
||||
item_id,
|
||||
DATE(created_at) as prod_date,
|
||||
COUNT(*) as total_qty
|
||||
")
|
||||
->where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->whereMonth('created_at', $month)
|
||||
->whereYear('created_at', $year)
|
||||
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
|
||||
->get()
|
||||
->groupBy(function ($row) {
|
||||
return $row->plant_id . '_' . $row->line_id . '_' . $row->item_id;
|
||||
})
|
||||
->map(function ($group) {
|
||||
return $group->keyBy('prod_date');
|
||||
});
|
||||
|
||||
$this->records = ProductionPlan::query()
|
||||
->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||
->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||
->where('production_plans.plant_id', $plantId)
|
||||
->where('production_plans.line_id', $lineId)
|
||||
->whereMonth('production_plans.created_at', $month)
|
||||
->whereYear('production_plans.created_at', $year)
|
||||
->select(
|
||||
'production_plans.item_id',
|
||||
'production_plans.plant_id',
|
||||
'production_plans.line_id',
|
||||
'production_plans.plan_quantity',
|
||||
'production_plans.working_days',
|
||||
'items.code as item_code',
|
||||
'items.description as item_description',
|
||||
'lines.name as line_name',
|
||||
'plants.name as plant_name'
|
||||
)
|
||||
->get()
|
||||
// ->map(function ($row) use ($producedData) {
|
||||
// $row = $row->toArray();
|
||||
|
||||
// $row['daily_target'] = ($row['working_days'] > 0)
|
||||
// ? round($row['plan_quantity'] / $row['working_days'], 2)
|
||||
// : 0;
|
||||
|
||||
// // $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||
|
||||
// // foreach ($this->dates as $date) {
|
||||
// // $found = $producedData[$key][$date] ?? null;
|
||||
// // $row['produced_quantity'][$date] = $found->total_qty ?? 0;
|
||||
// // }
|
||||
|
||||
// $remainingDays = $row['working_days'];
|
||||
// $pendingQty = 0;
|
||||
|
||||
// $row['daily_target_dynamic'] = [];
|
||||
// $row['produced_quantity'] = [];
|
||||
|
||||
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||
|
||||
// foreach ($this->dates as $date) {
|
||||
|
||||
// $found = $producedData[$key][$date] ?? null;
|
||||
// $producedQty = $found->total_qty ?? 0;
|
||||
|
||||
// // today's adjusted target
|
||||
// $todayTarget = $baseDailyTarget;
|
||||
|
||||
// if ($remainingDays > 1 && $pendingQty > 0) {
|
||||
// $todayTarget += $pendingQty / $remainingDays;
|
||||
// }
|
||||
|
||||
// $row['daily_target_dynamic'][$date] = round($todayTarget, 2);
|
||||
// $row['produced_quantity'][$date] = $producedQty;
|
||||
|
||||
// // calculate today's shortfall
|
||||
// $pendingQty += ($todayTarget - $producedQty);
|
||||
|
||||
// if ($pendingQty < 0) {
|
||||
// $pendingQty = 0;
|
||||
// }
|
||||
|
||||
// $remainingDays--;
|
||||
// }
|
||||
|
||||
// return $row;
|
||||
// })
|
||||
->map(function ($row) use ($producedData) {
|
||||
|
||||
$row = $row->toArray();
|
||||
|
||||
$remainingQty = $row['plan_quantity'];
|
||||
$remainingDays = $row['working_days'];
|
||||
|
||||
$row['daily_target_dynamic'] = [];
|
||||
$row['produced_quantity'] = [];
|
||||
|
||||
$key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||
|
||||
foreach ($this->dates as $date) {
|
||||
|
||||
// Skip leave dates
|
||||
if (in_array($date, $this->leaveDates)) {
|
||||
$row['daily_target_dynamic'][$date] = '-';
|
||||
$row['produced_quantity'][$date] = '-';
|
||||
continue;
|
||||
}
|
||||
|
||||
$todayTarget = $remainingDays > 0
|
||||
? round($remainingQty / $remainingDays, 2)
|
||||
: 0;
|
||||
|
||||
//$todayTarget = $remainingDays > 0
|
||||
// ? $remainingQty / $remainingDays
|
||||
// : 0;
|
||||
|
||||
$producedQty = isset($producedData[$key][$date])
|
||||
? $producedData[$key][$date]->total_qty
|
||||
: 0;
|
||||
|
||||
$row['daily_target_dynamic'][$date] = $todayTarget;
|
||||
$row['produced_quantity'][$date] = $producedQty;
|
||||
|
||||
// Carry forward pending
|
||||
$remainingQty -= $producedQty;
|
||||
if ($remainingQty < 0) {
|
||||
$remainingQty = 0;
|
||||
}
|
||||
|
||||
$remainingDays--;
|
||||
}
|
||||
|
||||
return $row;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function exportProductionData()
|
||||
{
|
||||
return Excel::download(
|
||||
new ProductionPlanExport($this->records, $this->dates),
|
||||
'production_plan_data.xlsx'
|
||||
);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// return view('livewire.production-target-plan');
|
||||
return view('livewire.production-target-plan', [
|
||||
'records' => $this->records,
|
||||
'dates' => $this->dates,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,13 @@ class Item extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'category',
|
||||
'code',
|
||||
'description',
|
||||
'hourly_quantity',
|
||||
'uom',
|
||||
'line_capacity',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -24,6 +26,11 @@ class Item extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function stickerMasters()
|
||||
{
|
||||
return $this->hasMany(StickerMaster::class, 'item_id', 'id');
|
||||
|
||||
@@ -13,6 +13,7 @@ class Line extends Model
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"block_id",
|
||||
"name",
|
||||
"type",
|
||||
"group_work_center",
|
||||
@@ -34,6 +35,11 @@ class Line extends Model
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function block(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Block::class);
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
|
||||
@@ -12,12 +12,15 @@ class ProductionPlan extends Model
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"item_id",
|
||||
"shift_id",
|
||||
"created_at",
|
||||
"line_id",
|
||||
"plan_quantity",
|
||||
"production_quantity",
|
||||
"operator_id",
|
||||
"working_days",
|
||||
"leave_dates",
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -34,4 +37,9 @@ class ProductionPlan extends Model
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class ProductionQuantity extends Model
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"machine_id",
|
||||
"shift_id",
|
||||
"line_id",
|
||||
"item_id",
|
||||
@@ -50,6 +51,11 @@ class ProductionQuantity extends Model
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($productionQuantity) {
|
||||
|
||||
46
app/Models/RequestQuotation.php
Normal file
46
app/Models/RequestQuotation.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestQuotation extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'rfq_number',
|
||||
'rfq_date_time',
|
||||
'pickup_address',
|
||||
'delivery_address',
|
||||
'weight',
|
||||
'volumetrice_size_inch',
|
||||
'type_of_vehicle',
|
||||
'special_type',
|
||||
'no_of_vehicle',
|
||||
'product_name',
|
||||
'loading_by',
|
||||
'unloading_by',
|
||||
'pick_and_delivery',
|
||||
'payment_term',
|
||||
'paid_topay',
|
||||
'require_date_time',
|
||||
'transporter_name',
|
||||
'total_freight_charge',
|
||||
'transit_day',
|
||||
'spot_rate_transport_master_id',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function spotRateTransportMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SpotRateTransportMaster::class);
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Models/RfqTransporterBid.php
Normal file
30
app/Models/RfqTransporterBid.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use phpseclib3\Crypt\Common\Formats\Signature\Raw;
|
||||
|
||||
class RfqTransporterBid extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'request_quotation_id',
|
||||
'transporter_name',
|
||||
'total_freight_charge',
|
||||
'transit_day',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function requestQuotation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RequestQuotation::class);
|
||||
// return $this->belongsTo(RequestQuotation::class, 'request_quotation_id');
|
||||
}
|
||||
}
|
||||
25
app/Models/SpotRateTransportMaster.php
Normal file
25
app/Models/SpotRateTransportMaster.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class SpotRateTransportMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts = [
|
||||
'user_name' => 'array',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'group_name',
|
||||
'user_name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
}
|
||||
@@ -13,11 +13,13 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use NotificationChannels\WebPush\HasPushSubscriptions;
|
||||
use NotificationChannels\WebPush\PushSubscription;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, HasRoles, Notifiable, SoftDeletes, HasSuperAdmin;
|
||||
use HasFactory, HasRoles, Notifiable, SoftDeletes, HasSuperAdmin, HasPushSubscriptions;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -63,4 +65,9 @@ class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function pushSubscriptions()
|
||||
{
|
||||
return $this->morphMany(PushSubscription::class, 'subscribable');
|
||||
}
|
||||
}
|
||||
|
||||
19
app/Models/WebPushSubscription.php
Normal file
19
app/Models/WebPushSubscription.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WebPushSubscription extends Model
|
||||
{
|
||||
protected $table = 'push_subscriptions';
|
||||
|
||||
protected $fillable = [
|
||||
'subscribable_type',
|
||||
'subscribable_id',
|
||||
'endpoint',
|
||||
'public_key',
|
||||
'auth_token',
|
||||
'content_encoding',
|
||||
];
|
||||
}
|
||||
108
app/Notifications/PushAlertNotification.php
Normal file
108
app/Notifications/PushAlertNotification.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\WebPush\WebPushMessage;
|
||||
use NotificationChannels\WebPush\WebPushChannel;
|
||||
|
||||
|
||||
class PushAlertNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
// public function __construct()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public $title;
|
||||
public $body;
|
||||
|
||||
public function __construct($title, $body)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
// public function via($notifiable)
|
||||
// {
|
||||
// return [WebPushChannel::class];
|
||||
// }
|
||||
|
||||
public function via($notifiable)
|
||||
{
|
||||
return [
|
||||
'database', // ✅ Filament toast
|
||||
WebPushChannel::class // ✅ Browser / PWA push
|
||||
];
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->title,
|
||||
'body' => $this->body,
|
||||
];
|
||||
}
|
||||
|
||||
// public function toWebPush($notifiable, $notification)
|
||||
// {
|
||||
// return (new WebPushMessage)
|
||||
// ->title('New Alert 🚨')
|
||||
// ->icon('/pwa-192x192.png')
|
||||
// ->body('You have a new notification')
|
||||
// ->action('Open App', 'open_app')
|
||||
// ->data(['url' => '/admin']);
|
||||
// }
|
||||
|
||||
public function toWebPush($notifiable, $notification)
|
||||
{
|
||||
|
||||
return (new WebPushMessage)
|
||||
->title($this->title)
|
||||
->icon('/pwa-192x192.png')
|
||||
->body($this->body)
|
||||
->action('Open App', 'open_app')
|
||||
->data(['url' => '/admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
// public function via(object $notifiable): array
|
||||
// {
|
||||
// return ['mail'];
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
// public function toMail(object $notifiable): MailMessage
|
||||
// {
|
||||
// return (new MailMessage)
|
||||
// ->line('The introduction to the notification.')
|
||||
// ->action('Notification Action', url('/'))
|
||||
// ->line('Thank you for using our application!');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
106
app/Policies/RequestQuotationPolicy.php
Normal file
106
app/Policies/RequestQuotationPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\RequestQuotation;
|
||||
use App\Models\User;
|
||||
|
||||
class RequestQuotationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, RequestQuotation $requestquotation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete RequestQuotation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any RequestQuotation');
|
||||
}
|
||||
}
|
||||
106
app/Policies/RfqTransporterBidPolicy.php
Normal file
106
app/Policies/RfqTransporterBidPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use App\Models\User;
|
||||
|
||||
class RfqTransporterBidPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, RfqTransporterBid $rfqtransporterbid): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete RfqTransporterBid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any RfqTransporterBid');
|
||||
}
|
||||
}
|
||||
106
app/Policies/SpotRateTransportMasterPolicy.php
Normal file
106
app/Policies/SpotRateTransportMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class SpotRateTransportMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, SpotRateTransportMaster $spotratetransportmaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete SpotRateTransportMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any SpotRateTransportMaster');
|
||||
}
|
||||
}
|
||||
106
app/Policies/StickerValidationPolicy.php
Normal file
106
app/Policies/StickerValidationPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\StickerValidation;
|
||||
use App\Models\User;
|
||||
|
||||
class StickerValidationPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, StickerValidation $stickervalidation): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete StickerValidation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any StickerValidation');
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Providers\Filament;
|
||||
|
||||
use Althinect\FilamentSpatieRolesPermissions\FilamentSpatieRolesPermissionsPlugin;
|
||||
use App\Filament\Pages\InvoiceDashboard;
|
||||
use App\Filament\Pages\NotificationSettings;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
@@ -59,6 +60,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
// ->widgets([
|
||||
@@ -123,6 +125,15 @@ class AdminPanelProvider extends PanelProvider
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
|
||||
FilamentView::registerRenderHook('panels::body.end', function () {
|
||||
if (url()->current() == config('app.url') . '/admin') {
|
||||
return '<script src="' . asset('js/push.js') . '"></script>';
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
|
||||
FilamentView::registerRenderHook('panels::head.end', function () {
|
||||
// Only inject on the "home" page (or specific route)
|
||||
if (url()->current() == config('app.url') . '/admin') {
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
"althinect/filament-spatie-roles-permissions": "^2.3",
|
||||
"diogogpinto/filament-auth-ui-enhancer": "^1.0",
|
||||
"erag/laravel-pwa": "^1.9",
|
||||
"ffhs/filament-package_ffhs_approvals": "^1.0",
|
||||
"filament/filament": "^3.3",
|
||||
"intervention/image": "^3.11",
|
||||
"irazasyed/telegram-bot-sdk": "^3.15",
|
||||
"laravel-notification-channels/webpush": "^10.4",
|
||||
"laravel/framework": "^11.31",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
|
||||
477
composer.lock
generated
477
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "69ede7e9877dd08efdeb795bfb6b7d29",
|
||||
"content-hash": "0e64d9b0a3c4d596ff8cd51b521c0565",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alperenersoy/filament-export",
|
||||
@@ -1810,6 +1810,85 @@
|
||||
},
|
||||
"time": "2025-10-17T16:34:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ffhs/filament-package_ffhs_approvals",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ffhs/filament-package_ffhs_approvals.git",
|
||||
"reference": "712475522b63bf45a9e63a649d391cfe22132818"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ffhs/filament-package_ffhs_approvals/zipball/712475522b63bf45a9e63a649d391cfe22132818",
|
||||
"reference": "712475522b63bf45a9e63a649d391cfe22132818",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"filament/filament": "^3.0",
|
||||
"php": "^8.2",
|
||||
"spatie/laravel-package-tools": "^1.15.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"larastan/larastan": "^3.0",
|
||||
"laravel/pint": "^1.0",
|
||||
"nunomaduro/collision": "^8.0",
|
||||
"orchestra/testbench": "^9.9",
|
||||
"pestphp/pest": "^3.7",
|
||||
"pestphp/pest-plugin-arch": "^3.0",
|
||||
"pestphp/pest-plugin-laravel": "^3.0",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-deprecation-rules": "^2.0",
|
||||
"phpstan/phpstan-phpunit": "^2.0",
|
||||
"spatie/laravel-ray": "^1.26"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"Approvals": "Ffhs\\Approvals\\Facades\\Approvals"
|
||||
},
|
||||
"providers": [
|
||||
"Ffhs\\Approvals\\ApprovalsServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ffhs\\Approvals\\": "src/",
|
||||
"Ffhs\\Approvals\\Database\\Factories\\": "database/factories/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kromer Luc",
|
||||
"email": "luc.kromer@ffhs.ch",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Matthew Ballou",
|
||||
"email": "mballou@kirschbaumdevelopment.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "This is my package filament-package_ffhs_approvals",
|
||||
"homepage": "https://github.com/ffhs/filament-package_ffhs_approvals",
|
||||
"keywords": [
|
||||
"ffhs",
|
||||
"filament-package_ffhs_approvals",
|
||||
"kirschbaum-development",
|
||||
"laravel"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ffhs/filament-package_ffhs_approvals/issues",
|
||||
"source": "https://github.com/ffhs/filament-package_ffhs_approvals"
|
||||
},
|
||||
"time": "2025-07-24T14:32:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "filament/actions",
|
||||
"version": "v3.3.45",
|
||||
@@ -3076,6 +3155,72 @@
|
||||
},
|
||||
"time": "2025-11-13T14:57:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel-notification-channels/webpush",
|
||||
"version": "10.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel-notification-channels/webpush.git",
|
||||
"reference": "a504bcbdd6258091b1fafdef6ca95b0891a47c9e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel-notification-channels/webpush/zipball/a504bcbdd6258091b1fafdef6ca95b0891a47c9e",
|
||||
"reference": "a504bcbdd6258091b1fafdef6ca95b0891a47c9e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/notifications": "^11.0|^12.0",
|
||||
"illuminate/support": "^11.0|^12.0",
|
||||
"minishlink/web-push": "^10.0",
|
||||
"php": "^8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"larastan/larastan": "^3.1",
|
||||
"laravel/pint": "^1.25",
|
||||
"mockery/mockery": "^1.0",
|
||||
"orchestra/testbench": "^9.2|^10.0",
|
||||
"phpunit/phpunit": "^10.5|^11.5.3",
|
||||
"rector/rector": "^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"NotificationChannels\\WebPush\\WebPushServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"NotificationChannels\\WebPush\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Cretu Eusebiu",
|
||||
"email": "me@cretueusebiu.com",
|
||||
"homepage": "http://cretueusebiu.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Joost de Bruijn",
|
||||
"email": "joost@aqualabs.nl",
|
||||
"role": "Maintainer"
|
||||
}
|
||||
],
|
||||
"description": "Web Push Notifications driver for Laravel.",
|
||||
"homepage": "https://github.com/laravel-notification-channels/webpush",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel-notification-channels/webpush/issues",
|
||||
"source": "https://github.com/laravel-notification-channels/webpush/tree/10.4.0"
|
||||
},
|
||||
"time": "2025-12-19T15:47:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v11.46.1",
|
||||
@@ -4880,6 +5025,73 @@
|
||||
},
|
||||
"time": "2019-10-05T02:44:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "minishlink/web-push",
|
||||
"version": "v10.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/web-push-libs/web-push-php.git",
|
||||
"reference": "08463189d3501cbd78a8625c87ab6680a7397aad"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/web-push-libs/web-push-php/zipball/08463189d3501cbd78a8625c87ab6680a7397aad",
|
||||
"reference": "08463189d3501cbd78a8625c87ab6680a7397aad",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"guzzlehttp/guzzle": "^7.9.2",
|
||||
"php": ">=8.2",
|
||||
"spomky-labs/base64url": "^2.0.4",
|
||||
"web-token/jwt-library": "^3.4.9|^4.0.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^v3.91.3",
|
||||
"phpstan/phpstan": "^2.1.33",
|
||||
"phpstan/phpstan-strict-rules": "^2.0",
|
||||
"phpunit/phpunit": "^11.5.46|^12.5.2",
|
||||
"symfony/polyfill-iconv": "^1.33"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Optional for performance.",
|
||||
"ext-gmp": "Optional for performance."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Minishlink\\WebPush\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Louis Lagrange",
|
||||
"email": "lagrange.louis@gmail.com",
|
||||
"homepage": "https://github.com/Minishlink"
|
||||
}
|
||||
],
|
||||
"description": "Web Push library for PHP",
|
||||
"homepage": "https://github.com/web-push-libs/web-push-php",
|
||||
"keywords": [
|
||||
"Push API",
|
||||
"WebPush",
|
||||
"notifications",
|
||||
"push",
|
||||
"web"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/web-push-libs/web-push-php/issues",
|
||||
"source": "https://github.com/web-push-libs/web-push-php/tree/v10.0.1"
|
||||
},
|
||||
"time": "2025-12-15T10:04:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "3.9.0",
|
||||
@@ -7696,6 +7908,180 @@
|
||||
],
|
||||
"time": "2025-09-24T06:40:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spomky-labs/base64url",
|
||||
"version": "v2.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Spomky-Labs/base64url.git",
|
||||
"reference": "7752ce931ec285da4ed1f4c5aa27e45e097be61d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Spomky-Labs/base64url/zipball/7752ce931ec285da4ed1f4c5aa27e45e097be61d",
|
||||
"reference": "7752ce931ec285da4ed1f4c5aa27e45e097be61d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/extension-installer": "^1.0",
|
||||
"phpstan/phpstan": "^0.11|^0.12",
|
||||
"phpstan/phpstan-beberlei-assert": "^0.11|^0.12",
|
||||
"phpstan/phpstan-deprecation-rules": "^0.11|^0.12",
|
||||
"phpstan/phpstan-phpunit": "^0.11|^0.12",
|
||||
"phpstan/phpstan-strict-rules": "^0.11|^0.12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Base64Url\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Florent Morselli",
|
||||
"homepage": "https://github.com/Spomky-Labs/base64url/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Base 64 URL Safe Encoding/Decoding PHP Library",
|
||||
"homepage": "https://github.com/Spomky-Labs/base64url",
|
||||
"keywords": [
|
||||
"base64",
|
||||
"rfc4648",
|
||||
"safe",
|
||||
"url"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Spomky-Labs/base64url/issues",
|
||||
"source": "https://github.com/Spomky-Labs/base64url/tree/v2.0.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Spomky",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/FlorentMorselli",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2020-11-03T09:10:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spomky-labs/pki-framework",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Spomky-Labs/pki-framework.git",
|
||||
"reference": "f0e9a548df4e3942886adc9b7830581a46334631"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Spomky-Labs/pki-framework/zipball/f0e9a548df4e3942886adc9b7830581a46334631",
|
||||
"reference": "f0e9a548df4e3942886adc9b7830581a46334631",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.10|^0.11|^0.12|^0.13|^0.14",
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"ekino/phpstan-banned-code": "^1.0|^2.0|^3.0",
|
||||
"ext-gmp": "*",
|
||||
"ext-openssl": "*",
|
||||
"infection/infection": "^0.28|^0.29|^0.31",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3",
|
||||
"phpstan/extension-installer": "^1.3|^2.0",
|
||||
"phpstan/phpstan": "^1.8|^2.0",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
|
||||
"phpstan/phpstan-phpunit": "^1.1|^2.0",
|
||||
"phpstan/phpstan-strict-rules": "^1.3|^2.0",
|
||||
"phpunit/phpunit": "^10.1|^11.0|^12.0",
|
||||
"rector/rector": "^1.0|^2.0",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"symfony/string": "^6.4|^7.0|^8.0",
|
||||
"symfony/var-dumper": "^6.4|^7.0|^8.0",
|
||||
"symplify/easy-coding-standard": "^12.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "For better performance (or GMP)",
|
||||
"ext-gmp": "For better performance (or BCMath)",
|
||||
"ext-openssl": "For OpenSSL based cyphering"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SpomkyLabs\\Pki\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joni Eskelinen",
|
||||
"email": "jonieske@gmail.com",
|
||||
"role": "Original developer"
|
||||
},
|
||||
{
|
||||
"name": "Florent Morselli",
|
||||
"email": "florent.morselli@spomky-labs.com",
|
||||
"role": "Spomky-Labs PKI Framework developer"
|
||||
}
|
||||
],
|
||||
"description": "A PHP framework for managing Public Key Infrastructures. It comprises X.509 public key certificates, attribute certificates, certification requests and certification path validation.",
|
||||
"homepage": "https://github.com/spomky-labs/pki-framework",
|
||||
"keywords": [
|
||||
"DER",
|
||||
"Private Key",
|
||||
"ac",
|
||||
"algorithm identifier",
|
||||
"asn.1",
|
||||
"asn1",
|
||||
"attribute certificate",
|
||||
"certificate",
|
||||
"certification request",
|
||||
"cryptography",
|
||||
"csr",
|
||||
"decrypt",
|
||||
"ec",
|
||||
"encrypt",
|
||||
"pem",
|
||||
"pkcs",
|
||||
"public key",
|
||||
"rsa",
|
||||
"sign",
|
||||
"signature",
|
||||
"verify",
|
||||
"x.509",
|
||||
"x.690",
|
||||
"x509",
|
||||
"x690"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Spomky-Labs/pki-framework/issues",
|
||||
"source": "https://github.com/Spomky-Labs/pki-framework/tree/1.4.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Spomky",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/FlorentMorselli",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2025-12-20T12:57:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/clock",
|
||||
"version": "v7.3.0",
|
||||
@@ -10504,6 +10890,95 @@
|
||||
}
|
||||
],
|
||||
"time": "2024-11-21T01:49:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "web-token/jwt-library",
|
||||
"version": "4.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/web-token/jwt-library.git",
|
||||
"reference": "690d4dd47b78f423cb90457f858e4106e1deb728"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/web-token/jwt-library/zipball/690d4dd47b78f423cb90457f858e4106e1deb728",
|
||||
"reference": "690d4dd47b78f423cb90457f858e4106e1deb728",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"brick/math": "^0.12|^0.13|^0.14",
|
||||
"php": ">=8.2",
|
||||
"psr/clock": "^1.0",
|
||||
"spomky-labs/pki-framework": "^1.2.1"
|
||||
},
|
||||
"conflict": {
|
||||
"spomky-labs/jose": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "GMP or BCMath is highly recommended to improve the library performance",
|
||||
"ext-gmp": "GMP or BCMath is highly recommended to improve the library performance",
|
||||
"ext-openssl": "For key management (creation, optimization, etc.) and some algorithms (AES, RSA, ECDSA, etc.)",
|
||||
"ext-sodium": "Sodium is required for OKP key creation, EdDSA signature algorithm and ECDH-ES key encryption with OKP keys",
|
||||
"paragonie/sodium_compat": "Sodium is required for OKP key creation, EdDSA signature algorithm and ECDH-ES key encryption with OKP keys",
|
||||
"spomky-labs/aes-key-wrap": "For all Key Wrapping algorithms (AxxxKW, AxxxGCMKW, PBES2-HSxxx+AyyyKW...)",
|
||||
"symfony/console": "Needed to use console commands",
|
||||
"symfony/http-client": "To enable JKU/X5U support."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jose\\Component\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Florent Morselli",
|
||||
"homepage": "https://github.com/Spomky"
|
||||
},
|
||||
{
|
||||
"name": "All contributors",
|
||||
"homepage": "https://github.com/web-token/jwt-framework/contributors"
|
||||
}
|
||||
],
|
||||
"description": "JWT library",
|
||||
"homepage": "https://github.com/web-token",
|
||||
"keywords": [
|
||||
"JOSE",
|
||||
"JWE",
|
||||
"JWK",
|
||||
"JWKSet",
|
||||
"JWS",
|
||||
"Jot",
|
||||
"RFC7515",
|
||||
"RFC7516",
|
||||
"RFC7517",
|
||||
"RFC7518",
|
||||
"RFC7519",
|
||||
"RFC7520",
|
||||
"bundle",
|
||||
"jwa",
|
||||
"jwt",
|
||||
"symfony"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/web-token/jwt-library/issues",
|
||||
"source": "https://github.com/web-token/jwt-library/tree/4.1.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Spomky",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/FlorentMorselli",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2025-12-18T14:27:35+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
||||
@@ -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
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE spot_rate_transport_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
group_name TEXT NOT NULL,
|
||||
user_name 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
|
||||
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('spot_rate_transport_masters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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 request_quotations (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
spot_rate_transport_master_id BIGINT NOT NULL,
|
||||
rfq_number TEXT NOT NULL,
|
||||
rfq_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
pickup_address TEXT NOT NULL,
|
||||
delivery_address TEXT NOT NULL,
|
||||
weight TEXT NOT NULL,
|
||||
volumetrice_size_inch TEXT NOT NULL,
|
||||
type_of_vehicle TEXT NOT NULL,
|
||||
special_type TEXT NOT NULL,
|
||||
no_of_vehicle TEXT NOT NULL,
|
||||
product_name TEXT NOT NULL,
|
||||
loading_by TEXT NOT NULL,
|
||||
unloading_by TEXT NOT NULL,
|
||||
pick_and_delivery TEXT NOT NULL,
|
||||
payment_term TEXT NOT NULL,
|
||||
paid_topay TEXT NOT NULL,
|
||||
require_date_time TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
rfq_rec_on_or_before TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
transporter_name TEXT NULL,
|
||||
total_freight_charge TEXT NULL,
|
||||
transit_day TEXT 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 (spot_rate_transport_master_id) REFERENCES spot_rate_transport_masters (id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('request_quotations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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 rfq_transporter_bids (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
request_quotation_id BIGINT NOT NULL,
|
||||
|
||||
transporter_name TEXT NULL,
|
||||
total_freight_charge TEXT NULL,
|
||||
transit_day TEXT 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 (request_quotation_id) REFERENCES request_quotations(id)
|
||||
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rfq_transporter_bids');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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'
|
||||
ALTER TABLE production_plans
|
||||
ADD COLUMN item_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT production_plans_item_id_fkey
|
||||
FOREIGN KEY (item_id) REFERENCES items(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('production_plans', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE lines
|
||||
ADD COLUMN block_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT lines_block_id_fkey
|
||||
FOREIGN KEY (block_id) REFERENCES blocks(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('lines', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE items
|
||||
ADD COLUMN line_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT items_line_id_fkey
|
||||
FOREIGN KEY (line_id) REFERENCES lines(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
ALTER TABLE items
|
||||
ADD COLUMN line_capacity TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('items', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
ALTER TABLE production_quantities
|
||||
ADD COLUMN machine_id BIGINT DEFAULT NULL,
|
||||
ADD CONSTRAINT production_quantities_machine_id_fkey
|
||||
FOREIGN KEY (machine_id) REFERENCES machines(id);
|
||||
SQL;
|
||||
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('production_quantities', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE production_plans
|
||||
ADD COLUMN working_days TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('production_plans', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE production_plans
|
||||
ADD COLUMN leave_dates TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('production_plans', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
113
public/js/push.js
Normal file
113
public/js/push.js
Normal file
@@ -0,0 +1,113 @@
|
||||
// async function registerPush() {
|
||||
// try {
|
||||
// console.log("Registering for push notifications");
|
||||
|
||||
// if (!('serviceWorker' in navigator)) {
|
||||
// console.error("ServiceWorker not supported");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const permission = await Notification.requestPermission();
|
||||
// console.log("Permission:", permission);
|
||||
|
||||
// if (permission !== 'granted') {
|
||||
// console.warn("Notification permission denied");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const registration = await navigator.serviceWorker.register('/sw.js');
|
||||
// console.log("SW registered:", registration);
|
||||
|
||||
// // const subscription = await registration.pushManager.subscribe({
|
||||
// // userVisibleOnly: true,
|
||||
// // applicationServerKey: vapidKey
|
||||
// // });
|
||||
// const subscription = await registration.pushManager.subscribe({
|
||||
// userVisibleOnly: true,
|
||||
// applicationServerKey: urlBase64ToUint8Array(vapidKey),
|
||||
// });
|
||||
|
||||
// console.log('VAPID key:', vapidKey);
|
||||
|
||||
// console.log("Subscription created:", subscription);
|
||||
|
||||
// const res = await fetch('/push/subscribe', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'X-CSRF-TOKEN': csrfToken
|
||||
// },
|
||||
// body: JSON.stringify(subscription)
|
||||
// });
|
||||
|
||||
// console.log("Server response:", await res.text());
|
||||
|
||||
// alert("Push enabled ✅");
|
||||
// } catch (e) {
|
||||
// console.error("Push registration failed ❌", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
async function registerPush() {
|
||||
try {
|
||||
console.log("Registering for push notifications");
|
||||
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
console.error("ServiceWorker not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
const permission = await Notification.requestPermission();
|
||||
if (permission !== 'granted') {
|
||||
console.warn("Notification permission denied");
|
||||
return;
|
||||
}
|
||||
|
||||
const registration = await navigator.serviceWorker.register('/sw.js');
|
||||
|
||||
// ✅ GET first
|
||||
let subscription = await registration.pushManager.getSubscription();
|
||||
|
||||
// ✅ CREATE only if not exists
|
||||
if (!subscription) {
|
||||
subscription = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: urlBase64ToUint8Array(vapidKey),
|
||||
});
|
||||
console.log("New subscription created");
|
||||
} else {
|
||||
console.log("Existing subscription reused");
|
||||
}
|
||||
|
||||
// 🔥 ALWAYS send to backend
|
||||
await fetch('/push/subscribe', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
},
|
||||
body: JSON.stringify(subscription)
|
||||
});
|
||||
|
||||
alert("Push enabled ✅");
|
||||
} catch (e) {
|
||||
console.error("Push registration failed ❌", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function urlBase64ToUint8Array(base64String) {
|
||||
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||
const base64 = (base64String + padding)
|
||||
.replace(/-/g, '+')
|
||||
.replace(/_/g, '/');
|
||||
|
||||
const rawData = window.atob(base64);
|
||||
const outputArray = new Uint8Array(rawData.length);
|
||||
|
||||
for (let i = 0; i < rawData.length; ++i) {
|
||||
outputArray[i] = rawData.charCodeAt(i);
|
||||
}
|
||||
return outputArray;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
let deferredPrompt;
|
||||
|
||||
/* -----------------------------
|
||||
ANDROID / CHROME INSTALL FLOW
|
||||
------------------------------*/
|
||||
window.addEventListener("beforeinstallprompt", (e) => {
|
||||
e.preventDefault();
|
||||
deferredPrompt = e;
|
||||
@@ -7,6 +10,55 @@ window.addEventListener("beforeinstallprompt", (e) => {
|
||||
// Prevent duplicate banner
|
||||
if (document.getElementById("install-banner")) return;
|
||||
|
||||
showInstallBanner({
|
||||
message: '📱 Install <b>Quality</b> App?',
|
||||
buttonText: 'Install',
|
||||
onClick: async () => {
|
||||
deferredPrompt.prompt();
|
||||
const { outcome } = await deferredPrompt.userChoice;
|
||||
console.log("User install choice:", outcome);
|
||||
deferredPrompt = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// /* -----------------------------
|
||||
// IOS SAFARI MANUAL INSTALL
|
||||
// ------------------------------*/
|
||||
// function isIosSafari() {
|
||||
// return (
|
||||
// /iP(ad|hone|od)/.test(navigator.userAgent) &&
|
||||
// /Safari/.test(navigator.userAgent) &&
|
||||
// !/CriOS|FxiOS|OPiOS/.test(navigator.userAgent)
|
||||
// );
|
||||
// }
|
||||
|
||||
// function isInStandaloneMode() {
|
||||
// return window.navigator.standalone == true;
|
||||
// }
|
||||
|
||||
// document.addEventListener("DOMContentLoaded", () => {
|
||||
// if (
|
||||
// isIosSafari() &&
|
||||
// !isInStandaloneMode() &&
|
||||
// !localStorage.getItem("iosInstallShown")
|
||||
// ) {
|
||||
// showInstallBanner({
|
||||
// message: '📱 Install <b>Quality</b> App<br><small>Tap Share ⬆️ → Add to Home Screen</small>',
|
||||
// buttonText: 'Got it',
|
||||
// onClick: () => {
|
||||
// localStorage.setItem("iosInstallShown", "1");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
/* -----------------------------
|
||||
COMMON INSTALL BANNER UI
|
||||
------------------------------*/
|
||||
function showInstallBanner({ message, buttonText, onClick }) {
|
||||
if (document.getElementById("install-banner")) return;
|
||||
|
||||
const banner = document.createElement("div");
|
||||
banner.id = "install-banner";
|
||||
banner.innerHTML = `
|
||||
@@ -24,7 +76,7 @@ window.addEventListener("beforeinstallprompt", (e) => {
|
||||
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
|
||||
z-index: 99999;
|
||||
">
|
||||
<span style="font-size: 16px;">📱 Install <b>Quality</b> App?</span><br>
|
||||
<span style="font-size: 16px;">${message}</span><br>
|
||||
<button id="installBtn" style="
|
||||
margin-top: 10px;
|
||||
background: white;
|
||||
@@ -34,22 +86,22 @@ window.addEventListener("beforeinstallprompt", (e) => {
|
||||
border-radius: 6px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
">Install</button>
|
||||
">${buttonText}</button>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(banner);
|
||||
|
||||
document.getElementById("installBtn").addEventListener("click", async () => {
|
||||
document.getElementById("installBtn").addEventListener("click", () => {
|
||||
banner.remove();
|
||||
deferredPrompt.prompt();
|
||||
const { outcome } = await deferredPrompt.userChoice;
|
||||
console.log("User install choice:", outcome);
|
||||
deferredPrompt = null;
|
||||
});
|
||||
onClick();
|
||||
});
|
||||
}
|
||||
|
||||
/* -----------------------------
|
||||
APP INSTALLED EVENT
|
||||
------------------------------*/
|
||||
window.addEventListener("appinstalled", () => {
|
||||
console.log("🎉 PDS installed successfully!");
|
||||
console.log("🎉 App installed successfully!");
|
||||
const banner = document.getElementById("install-banner");
|
||||
if (banner) banner.remove();
|
||||
});
|
||||
|
||||
BIN
public/logo-192.png
Normal file
BIN
public/logo-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
BIN
public/logo-512.png
Normal file
BIN
public/logo-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "Laravel PWA",
|
||||
"short_name": "LPT",
|
||||
"name": "QDS",
|
||||
"short_name": "qds",
|
||||
"background_color": "#6777ef",
|
||||
"display": "standalone",
|
||||
"description": "A Progressive Web Application setup for Laravel projects.",
|
||||
"theme_color": "#6777ef",
|
||||
"start_url": "/",
|
||||
"gcm_sender_id": "103953800507",
|
||||
"start_url": "/admin",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/logo-192.png",
|
||||
|
||||
20
public/service-worker.js
Normal file
20
public/service-worker.js
Normal file
@@ -0,0 +1,20 @@
|
||||
self.addEventListener('push', function (event) {
|
||||
console.log('[SW] Push received');
|
||||
|
||||
let payload = {};
|
||||
|
||||
if (event.data) {
|
||||
payload = event.data.json();
|
||||
}
|
||||
|
||||
const title = payload.title || 'New Notification';
|
||||
const options = {
|
||||
body: payload.body || '',
|
||||
icon: payload.icon || '/pwa-192x192.png',
|
||||
data: payload.data || {},
|
||||
};
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(title, options)
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
<x-filament-panels::page>
|
||||
{{-- <button
|
||||
type="button"
|
||||
class="filament-button filament-button-primary"
|
||||
onclick="registerPush()"
|
||||
>
|
||||
Enable Push Notifications
|
||||
</button> --}}
|
||||
|
||||
<div class="max-w-md mx-auto">
|
||||
<x-filament::card>
|
||||
<div class="text-center space-y-4">
|
||||
<h2 class="text-xl font-semibold">
|
||||
🔔 Stay Updated
|
||||
</h2>
|
||||
|
||||
<p class="text-sm text-gray-500">
|
||||
Enable push notifications to receive real-time alerts and updates.
|
||||
</p>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="registerPush()"
|
||||
class="
|
||||
filament-button
|
||||
filament-button-primary
|
||||
w-full
|
||||
flex items-center justify-center gap-2
|
||||
py-3
|
||||
rounded-lg
|
||||
shadow-sm
|
||||
hover:shadow-md
|
||||
transition
|
||||
"
|
||||
>
|
||||
<x-heroicon-o-bell class="w-5 h-5"/>
|
||||
<span class="font-medium">Enable Push Notifications</span>
|
||||
</button>
|
||||
</div>
|
||||
</x-filament::card>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vapidKey = "{{ config('webpush.vapid.public_key') }}";
|
||||
const csrfToken = "{{ csrf_token() }}";
|
||||
|
||||
async function registerPush() {
|
||||
if (!('serviceWorker' in navigator)) return;
|
||||
|
||||
const permission = await Notification.requestPermission();
|
||||
if (permission != 'granted') return;
|
||||
|
||||
const registration = await navigator.serviceWorker.register('/service-worker.js');
|
||||
|
||||
const subscription = await registration.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: vapidKey
|
||||
});
|
||||
|
||||
await fetch('/push/subscribe', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
},
|
||||
body: JSON.stringify(subscription)
|
||||
});
|
||||
alert("Push notifications enabled ✅");
|
||||
}
|
||||
</script>
|
||||
</x-filament-panels::page>
|
||||
13
resources/views/filament/pages/production-calender.blade.php
Normal file
13
resources/views/filament/pages/production-calender.blade.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<div class="space-y-4">
|
||||
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</x-filament-panels::page>
|
||||
@@ -45,7 +45,7 @@
|
||||
</div> --}}
|
||||
<div class="flex gap-6 -mt-6">
|
||||
<!-- Scan QR Code -->
|
||||
<div class="w-1/2">
|
||||
<div class="w-full">
|
||||
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
SCAN QR CODE
|
||||
</label>
|
||||
@@ -60,7 +60,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Last Scanned QR -->
|
||||
<div class="w-1/2">
|
||||
{{-- <div class="w-1/2">
|
||||
<label for="recent-qr-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
LAST SCANNED QR
|
||||
</label>
|
||||
@@ -71,7 +71,7 @@
|
||||
readonly
|
||||
wire:model="recent_qr"
|
||||
/>
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
19
resources/views/filament/pages/production-target.blade.php
Normal file
19
resources/views/filament/pages/production-target.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
<x-filament::button
|
||||
wire:click="export"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Export
|
||||
</x-filament::button>
|
||||
<div class="bg-white shadow rounded-xl p-4 mt-6">
|
||||
<livewire:production-target-plan />
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
14
resources/views/filament/pages/rfq-dashboard.blade.php
Normal file
14
resources/views/filament/pages/rfq-dashboard.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
{{-- {{ $this->form }} --}}
|
||||
</div>
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\RfqChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
14
resources/views/filament/pages/rfq-overview.blade.php
Normal file
14
resources/views/filament/pages/rfq-overview.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
{{-- {{ $this->form }} --}}
|
||||
</div>
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\RfqRankChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
19
resources/views/filament/pages/welcome.blade.php
Normal file
19
resources/views/filament/pages/welcome.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<h1 class="text-3xl font-bold mb-6">Welcome to CRI Digital Manufacturing IIOT</h1>
|
||||
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-64 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<p class="text-lg text-gray-600 mb-6">
|
||||
This dashboard provides real-time visibility into your manufacturing operations,
|
||||
enabling you to monitor production, track performance, and make data-driven decisions
|
||||
across plants and lines—all from one centralized platform.
|
||||
</p>
|
||||
|
||||
</x-filament-panels::page>
|
||||
151
resources/views/forms/calendar.blade.php
Normal file
151
resources/views/forms/calendar.blade.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<!-- <select id="yearSelect">
|
||||
<option value="">Select Year</option>
|
||||
</select> -->
|
||||
|
||||
|
||||
<div id="calendar" wire:ignore></div>
|
||||
|
||||
|
||||
<!-- <input type="text" name="working_days" placeholder="Working Days"> -->
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
let selectedDates = [];
|
||||
let calendarEl = document.getElementById('calendar');
|
||||
|
||||
var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
initialView: 'dayGridMonth',
|
||||
height: 600,
|
||||
showNonCurrentDates: true,
|
||||
|
||||
datesSet: function(info) {
|
||||
// Clear previous month selections
|
||||
selectedDates = [];
|
||||
|
||||
// Remove background events
|
||||
calendar.removeAllEvents();
|
||||
|
||||
// Recalculate working days for new month
|
||||
updateWorkingDays(info.view.currentStart);
|
||||
},
|
||||
|
||||
dateClick: function(info) {
|
||||
|
||||
let viewMonth = calendar.view.currentStart.getMonth();
|
||||
let clickedMonth = info.date.getMonth();
|
||||
|
||||
if (viewMonth != clickedMonth) return;
|
||||
|
||||
let dateStr = info.dateStr;
|
||||
|
||||
if (selectedDates.includes(dateStr)) {
|
||||
selectedDates = selectedDates.filter(d => d !== dateStr);
|
||||
|
||||
calendar.getEvents().forEach(event => {
|
||||
if (event.startStr == dateStr) event.remove();
|
||||
});
|
||||
|
||||
} else {
|
||||
selectedDates.push(dateStr);
|
||||
|
||||
calendar.addEvent({
|
||||
start: dateStr,
|
||||
display: 'background',
|
||||
color: '#f03f17'
|
||||
});
|
||||
}
|
||||
|
||||
updateWorkingDays(info.date);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// var calendar = new FullCalendar.Calendar(calendarEl, {
|
||||
// initialView: 'dayGridMonth',
|
||||
// height: 600,
|
||||
// showNonCurrentDates: true,
|
||||
|
||||
// dateClick: function(info) {
|
||||
|
||||
// let viewMonth = calendar.view.currentStart.getMonth();
|
||||
// let clickedMonth = info.date.getMonth();
|
||||
|
||||
// // let month = info.date.getMonth() + 1; // JS month: 0-11 → 1-12
|
||||
// // let year = info.date.getFullYear();
|
||||
|
||||
// if (viewMonth != clickedMonth) {
|
||||
// return; // Ignore next/prev month dates
|
||||
// }
|
||||
|
||||
// let dateStr = info.dateStr;
|
||||
|
||||
// if (selectedDates.includes(dateStr)) {
|
||||
// selectedDates = selectedDates.filter(d => d !== dateStr);
|
||||
|
||||
// calendar.getEvents().forEach(event => {
|
||||
// if (event.startStr == dateStr) {
|
||||
// event.remove();
|
||||
// }
|
||||
// });
|
||||
|
||||
// } else {
|
||||
// selectedDates.push(dateStr);
|
||||
|
||||
// calendar.addEvent({
|
||||
// start: dateStr,
|
||||
// display: 'background',
|
||||
// color: '#f03f17'
|
||||
// });
|
||||
// }
|
||||
|
||||
// updateWorkingDays(info.date);
|
||||
// }
|
||||
// });
|
||||
|
||||
// yearSelect.addEventListener('change', function () {
|
||||
// let year = this.value;
|
||||
// if (!year) return;
|
||||
|
||||
// let currentDate = calendar.getDate();
|
||||
// let newDate = new Date(year, currentDate.getMonth(), 1);
|
||||
|
||||
// calendar.gotoDate(newDate);
|
||||
// });
|
||||
|
||||
function updateWorkingDays(date) {
|
||||
let totalDays = new Date(
|
||||
date.getFullYear(),
|
||||
date.getMonth()+1,
|
||||
0
|
||||
).getDate();
|
||||
|
||||
let workingDays = totalDays - selectedDates.length;
|
||||
// document.querySelector('input[name="working_days"]').value = workingDays;
|
||||
|
||||
const input = document.querySelector('#working_days');
|
||||
|
||||
input.value = workingDays;
|
||||
|
||||
input.dispatchEvent(new Event('input'));
|
||||
|
||||
const monthInput = document.querySelector('#month');
|
||||
monthInput.value = date.getMonth() + 1; // 1–12 month number
|
||||
monthInput.dispatchEvent(new Event('input'));
|
||||
|
||||
const yearInput = document.querySelector('#year');
|
||||
yearInput.value = date.getFullYear();
|
||||
yearInput.dispatchEvent(new Event('input'));
|
||||
|
||||
const selectedDatesInput = document.querySelector('#selected_dates');
|
||||
selectedDatesInput.value = selectedDates.join(',');
|
||||
selectedDatesInput.dispatchEvent(new Event('input'));
|
||||
|
||||
}
|
||||
|
||||
calendar.render();
|
||||
});
|
||||
</script>
|
||||
9
resources/views/forms/save.php
Normal file
9
resources/views/forms/save.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="flex space-x-2 items-center">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center px-3 py-1 bg-primary-600 text-white rounded hover:bg-primary-700"
|
||||
wire:click="saveWorkingDays"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
85
resources/views/livewire/production-target-plan.blade.php
Normal file
85
resources/views/livewire/production-target-plan.blade.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<div class="p-4">
|
||||
<h2 class="text-lg font-bold mb-4 text-gray-700 uppercase tracking-wider">
|
||||
PRODUCTION PLAN TABLE:
|
||||
</h2>
|
||||
<div class="overflow-x-auto rounded-lg shadow">
|
||||
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
||||
{{-- <thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Created Datetime</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Created By</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Plant</th>
|
||||
<th class="border px-4 py-2">Line</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Item Code</th>
|
||||
<th class="border px-4 py-2">Production Plan Dates</th>
|
||||
</tr>
|
||||
</thead> --}}
|
||||
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||
<tr>
|
||||
<th class="border px-4 py-2" rowspan="3">No</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Plant</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Line</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Item Code</th>
|
||||
|
||||
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 2 }}" class="text-center">
|
||||
Production Plan Dates
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach($dates as $date)
|
||||
<th colspan="2" class="text-center">
|
||||
{{ $date }}
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
<tr>
|
||||
@foreach($dates as $date)
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Target Plan</th>
|
||||
<th class="border px-4 py-2 whitespace-nowrap">Produced Quantity</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($records as $index => $record)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['plant_name'] }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['line_name'] }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['item_code'] }}</td>
|
||||
|
||||
{{-- @foreach($dates as $date)
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['target_plan'][$date] ?? '-' }}</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['production_plan'][$date] ?? '-' }}</td>
|
||||
@endforeach --}}
|
||||
|
||||
@foreach($dates as $date)
|
||||
@if(in_array($date, $leaveDates))
|
||||
<td class="border px-4 py-2 whitespace-nowrap">-</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">-</td>
|
||||
@else
|
||||
{{-- <td class="border px-4 py-2 whitespace-nowrap">{{ $record['daily_target'] ?? '-' }}</td> --}}
|
||||
<td class="border px-4 py-2 whitespace-nowrap">
|
||||
{{ $record['daily_target_dynamic'][$date] ?? '-' }}
|
||||
</td>
|
||||
<td class="border px-4 py-2 whitespace-nowrap">
|
||||
{{ $record['produced_quantity'][$date] ?? '-' }}
|
||||
</td>
|
||||
{{-- <td class="border px-4 py-2 whitespace-nowrap">{{ $record['produced_quantity'] ?? '-' }}</td> --}}
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="9" class="px-4 py-4 text-center text-gray-500">
|
||||
No production plan data found.
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -25,12 +25,15 @@ use App\Http\Controllers\ObdController;
|
||||
use App\Http\Controllers\PalletController;
|
||||
use App\Http\Controllers\PdfController;
|
||||
use App\Http\Controllers\PlantController;
|
||||
use App\Http\Controllers\PrintController;
|
||||
use App\Http\Controllers\ProductionStickerReprintController;
|
||||
use App\Http\Controllers\SapFileController;
|
||||
use App\Http\Controllers\StickerMasterController;
|
||||
// use App\Http\Controllers\TelegramController;
|
||||
use App\Http\Controllers\TestingPanelController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Models\WebPushSubscription;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -185,3 +188,46 @@ Route::post('file/store', [SapFileController::class, 'store'])->name('file.store
|
||||
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']);
|
||||
|
||||
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
||||
|
||||
|
||||
Route::post('/print-pdf', [PrintController::class, 'print']);
|
||||
|
||||
|
||||
Route::post('/push/subscribe', function (Request $request) {
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
abort_if(!$user, 401);
|
||||
|
||||
$request->validate([
|
||||
'endpoint' => 'required|string',
|
||||
'keys.p256dh' => 'required|string',
|
||||
'keys.auth' => 'required|string',
|
||||
]);
|
||||
|
||||
// WebPushSubscription::updateOrCreate(
|
||||
// ['endpoint' => $request->endpoint],
|
||||
// [
|
||||
// 'subscribable_type' => get_class($user),
|
||||
// 'subscribable_id' => $user->id,
|
||||
// 'public_key' => $request->keys['p256dh'],
|
||||
// 'auth_token' => $request->keys['auth'],
|
||||
// 'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||
// ]
|
||||
// );
|
||||
|
||||
WebPushSubscription::updateOrCreate(
|
||||
[
|
||||
'endpoint' => $request->endpoint,
|
||||
'subscribable_type' => get_class($user),
|
||||
'subscribable_id' => $user->id,
|
||||
],
|
||||
[
|
||||
'public_key' => $request->keys['p256dh'],
|
||||
'auth_token' => $request->keys['auth'],
|
||||
'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\EquipmentMaster;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use App\Models\WebPushSubscription;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -17,6 +18,75 @@ use App\Http\Livewire\CustomLogin;
|
||||
return redirect('/admin');
|
||||
});
|
||||
|
||||
// Route::get('/admin', function () {
|
||||
// return redirect('/admin/welcome');
|
||||
// });
|
||||
|
||||
// Route::post('/push/subscribe', function (Request $request) {
|
||||
// $request->user()->updatePushSubscription(
|
||||
// $request->endpoint,
|
||||
// $request->keys['p256dh'],
|
||||
// $request->keys['auth']
|
||||
// );
|
||||
|
||||
// return response()->json(['success' => true]);
|
||||
// })->middleware('auth');
|
||||
|
||||
// Route::post('/push/subscribe', function (Request $request) {
|
||||
// $user = Filament::auth()->user();
|
||||
|
||||
// abort_if(!$user, 401);
|
||||
|
||||
// $user->updatePushSubscription(
|
||||
// $request->endpoint,
|
||||
// $request->keys['p256dh'],
|
||||
// $request->keys['auth'],
|
||||
// $request->contentEncoding ?? 'aesgcm'
|
||||
// );
|
||||
|
||||
// return response()->json(['success' => true]);
|
||||
// });
|
||||
|
||||
Route::post('/push/subscribe', function (Request $request) {
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
abort_if(!$user, 401);
|
||||
|
||||
$request->validate([
|
||||
'endpoint' => 'required|string',
|
||||
'keys.p256dh' => 'required|string',
|
||||
'keys.auth' => 'required|string',
|
||||
]);
|
||||
|
||||
WebPushSubscription::updateOrCreate(
|
||||
['endpoint' => $request->endpoint],
|
||||
[
|
||||
'subscribable_type' => get_class($user),
|
||||
'subscribable_id' => $user->id,
|
||||
'public_key' => $request->keys['p256dh'],
|
||||
'auth_token' => $request->keys['auth'],
|
||||
'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||
]
|
||||
);
|
||||
|
||||
// WebPushSubscription::updateOrCreate(
|
||||
// [
|
||||
// 'endpoint' => $request->endpoint,
|
||||
// 'subscribable_type' => get_class($user),
|
||||
// 'subscribable_id' => $user->id,
|
||||
// ],
|
||||
// [
|
||||
// 'public_key' => $request->keys['p256dh'],
|
||||
// 'auth_token' => $request->keys['auth'],
|
||||
// 'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||
// ]
|
||||
// );
|
||||
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
});
|
||||
|
||||
|
||||
// routes/web.php
|
||||
Route::post('/save-serials-to-session', function (Request $request) {
|
||||
session(['serial_numbers' => $request->serial_numbers]);
|
||||
|
||||
Reference in New Issue
Block a user