Merge pull request 'ranjith-dev' (#664) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #664
This commit was merged in pull request #664.
This commit is contained in:
@@ -17,6 +17,7 @@ use Filament\Infolists\Infolist;
|
|||||||
use Filament\Infolists\Components\ImageEntry;
|
use Filament\Infolists\Components\ImageEntry;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Infolists\Components\Section;
|
use Filament\Infolists\Components\Section;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class VisitorEntryResource extends Resource
|
class VisitorEntryResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -24,10 +25,35 @@ class VisitorEntryResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Gate Entry';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
|
Forms\Components\TextInput::make('register_id')
|
||||||
|
->label('Register ID')
|
||||||
|
->default(function () {
|
||||||
|
|
||||||
|
$datePart = Carbon::now()->format('ymd'); // 260527
|
||||||
|
|
||||||
|
$prefix = 'CRI' . $datePart . 'V';
|
||||||
|
|
||||||
|
// Get latest record for today
|
||||||
|
$lastRecord = VisitorEntry::where('register_id', 'like', $prefix . '%')
|
||||||
|
->latest('id')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($lastRecord) {
|
||||||
|
$lastNumber = (int) substr($lastRecord->register_id, -3);
|
||||||
|
$nextNumber = str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT);
|
||||||
|
} else {
|
||||||
|
$nextNumber = '001';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $prefix . $nextNumber;
|
||||||
|
})
|
||||||
|
->readOnly(),
|
||||||
Forms\Components\TextInput::make('mobile_number')
|
Forms\Components\TextInput::make('mobile_number')
|
||||||
->label('Mobile Number')
|
->label('Mobile Number')
|
||||||
->length(10)
|
->length(10)
|
||||||
@@ -140,9 +166,17 @@ class VisitorEntryResource extends Resource
|
|||||||
->default(1)
|
->default(1)
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\DateTimePicker::make('in_time')
|
Forms\Components\DateTimePicker::make('in_time')
|
||||||
->label('In Time'),
|
->label('In Time')
|
||||||
|
->required()
|
||||||
|
->default(now()),
|
||||||
Forms\Components\DateTimePicker::make('out_time')
|
Forms\Components\DateTimePicker::make('out_time')
|
||||||
->label('Out Time'),
|
->label('Out Time'),
|
||||||
|
Forms\Components\DateTimePicker::make('valid_upto')
|
||||||
|
->label('Valid Upto')
|
||||||
|
->after('in_time')
|
||||||
|
->validationMessages([
|
||||||
|
'after' => 'Valid Upto must be after the In Time.',
|
||||||
|
]),
|
||||||
Forms\Components\View::make('components.webcam-field')
|
Forms\Components\View::make('components.webcam-field')
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
Forms\Components\Hidden::make('photo'),
|
Forms\Components\Hidden::make('photo'),
|
||||||
@@ -178,6 +212,10 @@ class VisitorEntryResource extends Resource
|
|||||||
->defaultImageUrl(asset('images/profile.png'))
|
->defaultImageUrl(asset('images/profile.png'))
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->extraImgAttributes(['style' => 'border-radius: 6px; object-fit: cover;']),
|
->extraImgAttributes(['style' => 'border-radius: 6px; object-fit: cover;']),
|
||||||
|
Tables\Columns\TextColumn::make('register_id')
|
||||||
|
->label('Register ID')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('type')
|
Tables\Columns\TextColumn::make('type')
|
||||||
->label('Visitor Type')
|
->label('Visitor Type')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -218,6 +256,15 @@ class VisitorEntryResource extends Resource
|
|||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
|
Tables\Columns\TextColumn::make('valid_upto')
|
||||||
|
->label('Valid Upto')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->alignCenter()
|
||||||
|
->color(fn ($record) => $record->valid_upto && \Carbon\Carbon::parse($record->valid_upto)->isPast()
|
||||||
|
? 'danger'
|
||||||
|
: 'success'
|
||||||
|
),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
@@ -318,6 +365,14 @@ class VisitorEntryResource extends Resource
|
|||||||
TextEntry::make('out_time')
|
TextEntry::make('out_time')
|
||||||
->label('Out Time')
|
->label('Out Time')
|
||||||
->dateTime(),
|
->dateTime(),
|
||||||
|
TextEntry::make('valid_upto')
|
||||||
|
->label('Valid Upto')
|
||||||
|
->dateTime()
|
||||||
|
->badge()
|
||||||
|
->color(fn ($record) => $record->valid_upto && \Carbon\Carbon::parse($record->valid_upto)->isPast()
|
||||||
|
? 'danger'
|
||||||
|
: 'success'
|
||||||
|
),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(2),
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class VisitorEntry extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'mobile_number',
|
'mobile_number',
|
||||||
|
'register_id',
|
||||||
'name',
|
'name',
|
||||||
'company',
|
'company',
|
||||||
'purpose_of_visit',
|
'purpose_of_visit',
|
||||||
@@ -20,7 +21,8 @@ class VisitorEntry extends Model
|
|||||||
'out_time',
|
'out_time',
|
||||||
'photo',
|
'photo',
|
||||||
'employee_master_id',
|
'employee_master_id',
|
||||||
'number_of_person'
|
'number_of_person',
|
||||||
|
'valid_upto',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function employeeMaster(): BelongsTo
|
public function employeeMaster(): BelongsTo
|
||||||
|
|||||||
@@ -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
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE visitor_entries
|
||||||
|
ADD COLUMN register_id TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
|
||||||
|
$sql2 = <<<'SQL'
|
||||||
|
ALTER TABLE visitor_entries
|
||||||
|
ADD COLUMN valid_upto TIMESTAMP DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('visitor_entries', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
{{-- Header --}}
|
{{-- Header --}}
|
||||||
<div class="badge-header">
|
<div class="badge-header">
|
||||||
<span class="type">{{ strtoupper($visitor->type ?? 'VISITOR') }}</span>
|
<span class="type">{{ strtoupper($visitor->type ?? 'VISITOR') }}</span>
|
||||||
<span class="badge-id">#{{ str_pad($visitor->id, 5, '0', STR_PAD_LEFT) }}</span>
|
<span class="badge-id">#{{ strtoupper($visitor->register_id) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- Body --}}
|
{{-- Body --}}
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
<div class="field-row">
|
<div class="field-row">
|
||||||
<span class="field-label">Valid upto:</span>
|
<span class="field-label">Valid upto:</span>
|
||||||
<span class="field-value">
|
<span class="field-value">
|
||||||
{{ $visitor->out_time ? \Carbon\Carbon::parse($visitor->out_time)->format('d/m/Y H:i') : '—' }}
|
{{ $visitor->valid_upto ? \Carbon\Carbon::parse($visitor->valid_upto)->format('d/m/Y H:i') : '—' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="field-row">
|
<div class="field-row">
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
<div class="visitor-qr" style="margin-top:2mm;">
|
<div class="visitor-qr" style="margin-top:2mm;">
|
||||||
{!! QrCode::size(25)
|
{!! QrCode::size(25)
|
||||||
->margin(0)
|
->margin(0)
|
||||||
->generate($visitor->id) !!}
|
->generate($visitor->register_id) !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user