3 Commits

Author SHA1 Message Date
dhanabalan
1ba8934784 Merge branch 'master' of ssh://172.31.31.31:2222/poc/pds 2025-03-25 16:54:21 +05:30
dhanabalan
70a42a6651 After change datatype from citext to text 2025-03-25 15:02:25 +05:30
dhanabalan
8612cc08b1 Masters and Transaction table column type update CITEXT 2025-03-24 19:47:34 +05:30
21 changed files with 243 additions and 96 deletions

View File

@@ -16,7 +16,7 @@ class BlockResource extends Resource
{
protected static ?string $model = Block::class;
protected static ?string $navigationIcon = 'heroicon-c-home-modern';
protected static ?string $navigationIcon = 'heroicon-c-building-library';
protected static ?string $navigationGroup = 'Master Entries';

View File

@@ -27,6 +27,7 @@ class CompanyResource extends Resource
->schema([
Forms\Components\TextInput::make('name')
->required()
//->citext('name')
->unique()
->columnSpanFull(),
]);

View File

@@ -40,6 +40,15 @@ class ItemResource extends Resource
Forms\Components\Textarea::make('description')
->required()
->columnSpanFull(),
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('block_id')
->relationship('block', 'name')
->required(),
Forms\Components\Select::make('line_id')
->relationship('line', 'name')
->required(),
]);
}
@@ -58,6 +67,12 @@ class ItemResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('description')
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->sortable(),
Tables\Columns\TextColumn::make('block.name')
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()

View File

@@ -17,7 +17,7 @@ class PlantResource extends Resource
{
protected static ?string $model = Plant::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-s-building-office-2';
protected static ?string $navigationGroup = 'Master Entries';
@@ -61,6 +61,8 @@ class PlantResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('name')
->sortable(),
Tables\Columns\TextColumn::make('address')
->sortable(),
Tables\Columns\TextColumn::make('company.name')
->sortable(),
Tables\Columns\TextColumn::make('created_at')

View File

@@ -25,12 +25,12 @@ class ProductionLineStopResource extends Resource
{
return $form
->schema([
Forms\Components\Select::make('code_id')
Forms\Components\Select::make('lineStop_id')
->relationship('linestop', 'code')
->required(),
Forms\Components\Textarea::make('reason')
Forms\Components\Select::make('lineStop_id')
->relationship('linestop', 'reason')
->required(),
//->columnSpanFull(),
Forms\Components\DateTimePicker::make('from_datetime')
->required(),
Forms\Components\DateTimePicker::make('to_datetime')
@@ -66,7 +66,7 @@ class ProductionLineStopResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('linestop.code')
->sortable(),
Tables\Columns\TextColumn::make('reason')
Tables\Columns\TextColumn::make('linestop.reason')
->sortable(),
Tables\Columns\TextColumn::make('from_datetime')
->dateTime()

View File

@@ -27,16 +27,13 @@ class ProductionQuantityResource extends Resource
{
return $form
->schema([
Forms\Components\TextInput::make('plan_quantity')
->required()
->numeric(),
Forms\Components\TextInput::make('hourly_quantity')
->required()
->numeric(),
Forms\Components\TextInput::make('item_code')
->required()
->autocapitalize('item_code'),
//->columnSpanFull(),
Forms\Components\Select::make('item_id')
->relationship('item', 'code')
->required(),
// Forms\Components\TextInput::make('item_code')
// ->required()
// ->autocapitalize('item_code'),
// //->columnSpanFull(),
Forms\Components\TextInput::make('serial_number')
->required()
->autocapitalize('serial_number'),

View File

@@ -14,23 +14,38 @@ class ItemOverview extends ChartWidget
protected function getData(): array
{
$activeFilter = $this->filter;
// Get selected values from the plant and line filter form inputs
$selectedPlant = request()->input('plant'); // Assuming form input name is 'plant'
$selectedLine = request()->input('line'); // Assuming form input name is 'line'
$query = \DB::table('production_quantities')
->selectRaw('EXTRACT(HOUR FROM created_at) AS hour, SUM(hourly_quantity) AS total_quantity')
->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()])
->groupByRaw('EXTRACT(HOUR FROM created_at)')
->selectRaw('EXTRACT(HOUR FROM created_at) AS hour, COUNT(*) AS total_quantity')
->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()]);
// Apply filters only if values are selected
if (!empty($selectedPlant)) {
$query->where('plant', $selectedPlant);
}
if (!empty($selectedLine)) {
$query->where('line', $selectedLine);
}
$query = $query->groupByRaw('EXTRACT(HOUR FROM created_at)')
->orderByRaw('EXTRACT(HOUR FROM created_at)')
->pluck('total_quantity', 'hour')
->toArray();
// Initialize data for each hour interval (8 AM - 7 PM)
$data = array_fill(8, 12, 0); // 8 AM to 7 PM (indexes 8 to 19)
// Populate actual values
// foreach ($query as $record) {
// $hour = (int) $record->hour;
// if ($hour >= 8 && $hour <= 19) {
// $data[$hour] = $record->total_quantity; // Assign only the hourly production
// }
// }
$data = array_fill(8, 12, 0);
// Populate actual values
// foreach ($query as $record) {
// $hour = (int) $record->hour;
// if ($hour >= 8 && $hour <= 19) {
// $data[$hour] = $record->total_quantity; // Assign only the hourly production
// }
// }
// Convert data to chart format
return [
@@ -47,44 +62,6 @@ class ItemOverview extends ChartWidget
'labels' => array_map(fn($h) => ($h <= 11 ? "$h AM" : ($h == 12 ? "12 PM" : ($h - 12) . " PM")), array_keys($data)),
];
// // Initialize data for each hour interval (8 AM - 7 PM)
// $data = [
// '8 AM - 9 AM' => 0, '9 AM - 10 AM' => 0, '10 AM - 11 AM' => 0, '11 AM - 12 PM' => 0,
// '12 PM - 1 PM' => 0, '1 PM - 2 PM' => 0, '2 PM - 3 PM' => 0, '3 PM - 4 PM' => 0,
// '4 PM - 5 PM' => 0, '5 PM - 6 PM' => 0, '6 PM - 7 PM' => 0, '7 PM - 8 PM' => 0,
// ];
// // Populate actual values
// foreach ($query as $record) {
// $hour = (int) $record->hour;
// if ($hour >= 8 && $hour <= 19) {
// $index = ($hour - 8); // Match hour to array index
// $labels = array_keys($data); // Get labels
// // Store only the production for that specific hour
// $data[$labels[$index]] = $record->total_quantity;
// }
// }
// // Debugging: Check if data exists
// if (empty($query) || array_sum($data) === 0) {
// \Log::info('No production data found for today.');
// }
// return [
// 'datasets' => [
// [
// 'label' => 'Production Quantities',
// 'data' => array_values($data),
// 'borderColor' => 'rgba(75, 192, 192, 1)',
// 'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
// 'fill' => true,
// ],
// ],
// 'labels' => array_keys($data),
// ];
}
protected function getType(): string

View File

@@ -4,14 +4,33 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Item extends Model
{
use SoftDeletes;
protected $fillable = [
"plant_id",
"block_id",
"line_id",
'code',
'description',
'hourly_quantity',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function block(): BelongsTo
{
return $this->belongsTo(Block::class);
}
public function line(): BelongsTo
{
return $this->belongsTo(Line::class);
}
}

View File

@@ -15,8 +15,7 @@ class ProductionLineStop extends Model
"block_id",
"shift_id",
"line_id",
"code_id",
"reason",
"lineStop_id",
"from_datetime",
"to_datetime",
"stop_hour",

View File

@@ -15,9 +15,7 @@ class ProductionQuantity extends Model
"block_id",
"shift_id",
"line_id",
"plan_quantity",
"hourly_quantity",
"item_code",
"item_id",
"serial_number",
];
@@ -40,4 +38,9 @@ class ProductionQuantity extends Model
{
return $this->belongsTo(Line::class);
}
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
// use Doctrine\DBAL\Types\Type;
class AppServiceProvider extends ServiceProvider
{
@@ -23,5 +24,9 @@ class AppServiceProvider extends ServiceProvider
Gate::before(function ($user, $ability) {
return $user->hasRole('Super Admin') ? true : null;
});
// if (!Type::hasType('citext')) {
// Type::addType('citext', \Doctrine\DBAL\Platforms\PostgreSqlPlatform::class);
// }
}
}

View File

@@ -10,7 +10,8 @@
"althinect/filament-spatie-roles-permissions": "^2.3",
"filament/filament": "^3.3",
"laravel/framework": "^11.31",
"laravel/tinker": "^2.9"
"laravel/tinker": "^2.9",
"tpetry/laravel-postgresql-enhanced": "^2.3"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.5",

139
composer.lock generated
View File

@@ -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": "292ea7e3ed35e47bcbea3972cfa9bb78",
"content-hash": "7b2a34f16f1fa4714c137023cb652961",
"packages": [
{
"name": "althinect/filament-spatie-roles-permissions",
@@ -5031,6 +5031,69 @@
],
"time": "2025-02-28T20:29:57+00:00"
},
{
"name": "spatie/regex",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/regex.git",
"reference": "d543de2019a0068e7b80da0ba24f1c51c7469303"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/regex/zipball/d543de2019a0068e7b80da0ba24f1c51c7469303",
"reference": "d543de2019a0068e7b80da0ba24f1c51c7469303",
"shasum": ""
},
"require": {
"php": "^8.0|^8.1"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Regex\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sebastian De Deyne",
"email": "sebastian@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "A sane interface for php's built in preg_* functions",
"homepage": "https://github.com/spatie/regex",
"keywords": [
"expression",
"expressions",
"regex",
"regular",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/regex/issues",
"source": "https://github.com/spatie/regex/tree/3.1.1"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2021-11-30T21:13:59+00:00"
},
{
"name": "symfony/clock",
"version": "v7.2.0",
@@ -7383,6 +7446,80 @@
},
"time": "2024-12-21T16:25:41+00:00"
},
{
"name": "tpetry/laravel-postgresql-enhanced",
"version": "2.3.4",
"source": {
"type": "git",
"url": "https://github.com/tpetry/laravel-postgresql-enhanced.git",
"reference": "a242704496e1cff76193a552128940bfa59d1466"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tpetry/laravel-postgresql-enhanced/zipball/a242704496e1cff76193a552128940bfa59d1466",
"reference": "a242704496e1cff76193a552128940bfa59d1466",
"shasum": ""
},
"require": {
"doctrine/dbal": "^2.6|^3.5|^4.0",
"illuminate/container": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/database": "^6.0|^7.0|^8.79|^9.0|^10.0|^11.0|^12.0",
"illuminate/events": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
"php": "^8.0",
"spatie/regex": "^2.0|^3.0"
},
"require-dev": {
"composer/semver": "^3.4",
"friendsofphp/php-cs-fixer": "^2.19.3|^3.5.0",
"larastan/larastan": "^1.0|^2.1|^3.0",
"nesbot/carbon": "^2.7|^3.3",
"orchestra/testbench": "^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.5|^2.0",
"phpunit/phpunit": "^8.5.23|^9.5.13|^10.5|^11.4",
"ramsey/uuid": "^3.9|^4.7"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Tpetry\\PostgresqlEnhanced\\PostgresqlEnhancedServiceProvider"
]
},
"phpstan": {
"includes": [
"phpstan-extension.neon"
]
}
},
"autoload": {
"psr-4": {
"Tpetry\\PostgresqlEnhanced\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "tpetry",
"email": "tobias@tpetry.me"
}
],
"description": "Support for many missing PostgreSQL specific features",
"homepage": "https://github.com/tpetry/laravel-postgresql-enhanced",
"keywords": [
"laravel",
"postgresql"
],
"support": {
"issues": "https://github.com/tpetry/laravel-postgresql-enhanced/issues",
"source": "https://github.com/tpetry/laravel-postgresql-enhanced/tree/2.3.4"
},
"time": "2025-03-06T10:30:15+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.6.1",

View File

@@ -13,7 +13,7 @@ return new class extends Migration
$sql = <<<'SQL'
CREATE TABLE companies (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
name CITEXT NOT NULL UNIQUE,
name TEXT NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),

View File

@@ -14,11 +14,11 @@ return new class extends Migration
CREATE TABLE plants (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
code INT NOT NULL CHECK (code >= 1000) UNIQUE,
company_id BIGINT NOT NULL,
name CITEXT NOT NULL UNIQUE, -- CITEXT use extension
address CITEXT NOT NULL,
code INT NOT NULL CHECK (code >= 1000) UNIQUE,
name TEXT NOT NULL UNIQUE, -- CITEXT use extension
address TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),

View File

@@ -14,8 +14,8 @@ return new class extends Migration
CREATE TABLE blocks (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
name CITEXT NOT NULL,
plant_id BIGINT NOT NULL,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),

View File

@@ -14,7 +14,7 @@ return new class extends Migration
CREATE TABLE shifts (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
name CITEXT NOT NULL,
name TEXT NOT NULL,
block_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,

View File

@@ -18,8 +18,8 @@ return new class extends Migration
block_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,
code CITEXT NOT NULL CHECK (LENGTH(code) >= 6),
description CITEXT NOT NULL,
code TEXT NOT NULL CHECK (LENGTH(code) >= 6),
description TEXT NOT NULL,
hourly_quantity INT NOT NULL CHECK (hourly_quantity > 0),

View File

@@ -18,9 +18,7 @@ return new class extends Migration
shift_id BIGINT NOT NULL,
block_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,
code_id BIGINT NOT NULL,
reason TEXT NOT NULL,
lineStop_id BIGINT NOT NULL,
from_datetime TIMESTAMP NOT NULL,
to_datetime TIMESTAMP NOT NULL,
@@ -35,7 +33,7 @@ return new class extends Migration
FOREIGN KEY (shift_id) REFERENCES shifts (id),
FOREIGN KEY (block_id) REFERENCES blocks (id),
FOREIGN KEY (plant_id) REFERENCES plants (id),
FOREIGN KEY (code_id) REFERENCES line_stops (id)
FOREIGN KEY (lineStop_id) REFERENCES line_stops (id)
);
SQL;

View File

@@ -19,15 +19,16 @@ return new class extends Migration
shift_id BIGINT NOT NULL,
block_id BIGINT NOT NULL,
plant_id BIGINT NOT NULL,
item_id BIGINT NOT NULL,
item_code TEXT NOT NULL,
serial_number TEXT NOT NULL,
serial_number TEXT NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
UNIQUE (item_code, serial_number),
UNIQUE (item_id, serial_number),
FOREIGN KEY (item_id) REFERENCES items (id),
FOREIGN KEY (line_id) REFERENCES lines (id),
FOREIGN KEY (shift_id) REFERENCES shifts (id),
FOREIGN KEY (block_id) REFERENCES blocks (id),

View File

@@ -20,14 +20,6 @@ class UserSeeder extends Seeder
$user1->assignRole('Super Admin');
$user2 = User::create([
'name' => 'Admin',
'email' => 'admin@cripumps.com',
'password' => bcrypt('admin'),
]);
$user2->assignRole('Super Admin');
User::factory()->count(10)->create();
}
}