Merge pull request 'ranjith-dev' (#865) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 25s

Reviewed-on: #865
This commit was merged in pull request #865.
This commit is contained in:
2026-07-26 05:22:22 +00:00
2 changed files with 114 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ use App\Filament\Resources\VisitorEntryResource\Pages;
use App\Filament\Resources\VisitorEntryResource\RelationManagers; use App\Filament\Resources\VisitorEntryResource\RelationManagers;
use App\Models\VisitorEntry; use App\Models\VisitorEntry;
use App\Models\EmployeeMaster; use App\Models\EmployeeMaster;
use App\Models\DealerVisitPlan;
use App\Models\Plant; use App\Models\Plant;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
@@ -28,6 +29,7 @@ use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Radio;
class VisitorEntryResource extends Resource class VisitorEntryResource extends Resource
{ {
@@ -95,11 +97,13 @@ class VisitorEntryResource extends Resource
$set('mobile_number', $employeeExist->mobile_number); $set('mobile_number', $employeeExist->mobile_number);
$set('company', $plant->name); $set('company', $plant->name);
$set('type', 'InterUnitStaff'); $set('type', 'InterUnitStaff');
$set('dealer', null);
} else { } else {
$set('name', null); $set('name', null);
$set('mobile_number', null); $set('mobile_number', null);
$set('company', null); $set('company', null);
$set('type', null); $set('type', null);
$set('dealer', null);
} }
} }
else else
@@ -109,6 +113,92 @@ class VisitorEntryResource extends Resource
$set('company', null); $set('company', null);
$set('type', null); $set('type', null);
}
}),
Forms\Components\Select::make('dealer')
->label('Dealer Visit')
->options(
DealerVisitPlan::where('status', 'Planned')
->whereDate('visit_plan_date', today())
->select('organizer', 'company', 'name')
->distinct()
->orderBy('organizer')
->get()
->mapWithKeys(function ($dealer) {
$key = "{$dealer->organizer}|{$dealer->company}|{$dealer->name}";
return [
$key => "{$dealer->organizer} ({$dealer->company}) ({$dealer->name})"
];
})
)
->searchable()
->reactive()
->afterStateUpdated(function (callable $set, callable $get, $state) {
if(!$state){
$set('name', null);
$set('inter_unit', null);
$set('company', null);
$set('type', null);
$set('number_of_person', null);
$set('purpose_of_visit', null);
$set('department', null);
$set('employee_master_id', null);
return;
}
[$organizer, $company, $name] = explode('|', $state);
$dealer = DealerVisitPlan::where('organizer', $organizer)
->where('company', $company)
->where('name', $name)
->where('status', 'Planned')
->whereDate('visit_plan_date', today())
->first();
if($dealer){
$organizerExist = DealerVisitPlan::where('organizer', $organizer)->where('name', $name)->where('company', $company)->latest()->first();
$empDepart = EmployeeMaster::where('id', $dealer->employee_master_id)->first();
if ($organizerExist) {
$set('name', $organizerExist->name);
$set('company', $organizerExist->company);
$set('number_of_person', $organizerExist->number_of_person);
$set('purpose_of_visit', $organizerExist->purpose_of_visit);
$set('type', 'Dealers');
$set('department', $empDepart->department);
$set('organizer', $organizerExist->organizer);
$set('inter_unit', null);
$set('mobile_number', $organizerExist->mobile_number);
$set('mode_of_travel', $organizerExist->mode_of_travel);
} else {
$set('name', null);
$set('mobile_number', null);
$set('inter_unit', null);
$set('company', null);
$set('type', null);
$set('number_of_person', null);
$set('purpose_of_visit', null);
$set('department', null);
// $set('employee_master_id', null);
$set('code', null);
$set('mode_of_travel', null);
}
}
else
{
$set('name', null);
$set('company', null);
$set('type', null);
$set('number_of_person', null);
$set('purpose_of_visit', null);
$set('mode_of_travel', null);
$set('mobile_number', null);
} }
}), }),
Forms\Components\TextInput::make('mobile_number') Forms\Components\TextInput::make('mobile_number')
@@ -148,7 +238,8 @@ class VisitorEntryResource extends Resource
'Supplier' => 'Supplier', 'Supplier' => 'Supplier',
'InterUnitStaff' => 'Inter Unit Staff', 'InterUnitStaff' => 'Inter Unit Staff',
'InterviewCandidates' => 'Interview Candidates', 'InterviewCandidates' => 'Interview Candidates',
'Customers/Dealers' => 'Customers/Dealers', 'Customers' => 'Customers',
'Dealers' => 'Dealers',
'Bankers' => 'Bankers', 'Bankers' => 'Bankers',
'ServiceProviders' => 'Service Providers', 'ServiceProviders' => 'Service Providers',
'GovermentOfficials' => 'Government Officials', 'GovermentOfficials' => 'Government Officials',
@@ -271,6 +362,8 @@ class VisitorEntryResource extends Resource
->validationMessages([ ->validationMessages([
'after' => 'Valid Upto must be after the In Time.', 'after' => 'Valid Upto must be after the In Time.',
]), ]),
Forms\Components\Hidden::make('organizer')
->label('Organizer'),
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'),
@@ -317,8 +410,13 @@ class VisitorEntryResource extends Resource
->alignCenter() ->alignCenter()
->searchable() ->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('organizer')
->label('Organizer')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('mobile_number') Tables\Columns\TextColumn::make('mobile_number')
->label('Visitor Mobile Number') ->label('Mobile Number')
->alignCenter() ->alignCenter()
->searchable() ->searchable()
->searchable() ->searchable()

View File

@@ -3,8 +3,10 @@
namespace App\Filament\Resources\VisitorEntryResource\Pages; namespace App\Filament\Resources\VisitorEntryResource\Pages;
use App\Filament\Resources\VisitorEntryResource; use App\Filament\Resources\VisitorEntryResource;
use App\Models\DealerVisitPlan;
use App\Models\EmployeeMaster; use App\Models\EmployeeMaster;
use App\Models\VisitorEntry; use App\Models\VisitorEntry;
use Carbon\Carbon;
use Filament\Actions; use Filament\Actions;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
@@ -139,6 +141,18 @@ class CreateVisitorEntry extends CreateRecord
else{ else{
\Log::warning('No email found for employee ID: ' . $visitor->employee_master_id); \Log::warning('No email found for employee ID: ' . $visitor->employee_master_id);
} }
if ($visitor->type == 'Dealer') {
DealerVisitPlan::where('name', $visitor->name)
->where('company', $visitor->company)
->where('mobile_number', $visitor->mobile_number)
->whereDate('visit_plan_date', today())
->where('status', 'Planned')
->update([
'status' => 'Completed',
]);
}
} }
protected function getRedirectUrl(): string protected function getRedirectUrl(): string