Compare commits
1 Commits
master
...
renovate/a
| Author | SHA1 | Date | |
|---|---|---|---|
| 961c281c02 |
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Exports;
|
|
||||||
|
|
||||||
use App\Models\DealerVisitPlan;
|
|
||||||
use Filament\Actions\Exports\ExportColumn;
|
|
||||||
use Filament\Actions\Exports\Exporter;
|
|
||||||
use Filament\Actions\Exports\Models\Export;
|
|
||||||
|
|
||||||
class DealerVisitPlanExporter extends Exporter
|
|
||||||
{
|
|
||||||
protected static ?string $model = DealerVisitPlan::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
static $rowNumber = 0;
|
|
||||||
return [
|
|
||||||
ExportColumn::make('no')
|
|
||||||
->label('NO')
|
|
||||||
->state(function ($record) use (&$rowNumber) {
|
|
||||||
// Increment and return the row number
|
|
||||||
return ++$rowNumber;
|
|
||||||
}),
|
|
||||||
ExportColumn::make('name')
|
|
||||||
->label('DEALER NAME'),
|
|
||||||
ExportColumn::make('company')
|
|
||||||
->label('DEALER COMPANY'),
|
|
||||||
ExportColumn::make('visit_plan_date')
|
|
||||||
->label('VISIT PLAN DATE'),
|
|
||||||
ExportColumn::make('organizer')
|
|
||||||
->label('ORGANIZER'),
|
|
||||||
ExportColumn::make('employeeMaster.name')
|
|
||||||
->label('RECIPIENT NAME'),
|
|
||||||
ExportColumn::make('number_of_person')
|
|
||||||
->label('NUMBER OF PERSON'),
|
|
||||||
ExportColumn::make('purpose_of_visit')
|
|
||||||
->label('PURPOSE OF VISIT'),
|
|
||||||
ExportColumn::make('status')
|
|
||||||
->label('STATUS'),
|
|
||||||
ExportColumn::make('created_at')
|
|
||||||
->label('CREATED AT'),
|
|
||||||
ExportColumn::make('updated_at')
|
|
||||||
->label('UPDATED AT'),
|
|
||||||
ExportColumn::make('created_by')
|
|
||||||
->label('CREATED BY'),
|
|
||||||
ExportColumn::make('updated_by')
|
|
||||||
->label('UPDATED BY'),
|
|
||||||
ExportColumn::make('deleted_at')
|
|
||||||
->label('DELETED AT')
|
|
||||||
->enabledByDefault(false),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Export $export): string
|
|
||||||
{
|
|
||||||
$body = 'Your dealer visit plan export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Imports;
|
|
||||||
|
|
||||||
use App\Models\DealerVisitPlan;
|
|
||||||
use App\Models\EmployeeMaster;
|
|
||||||
use App\Models\Plant;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Filament\Actions\Imports\ImportColumn;
|
|
||||||
use Filament\Actions\Imports\Importer;
|
|
||||||
use Filament\Actions\Imports\Models\Import;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Str;
|
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DealerVisitPlanImporter extends Importer
|
|
||||||
{
|
|
||||||
protected static ?string $model = DealerVisitPlan::class;
|
|
||||||
|
|
||||||
public static function getColumns(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ImportColumn::make('name')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Dealer Name')
|
|
||||||
->example('Suresh')
|
|
||||||
->label('Dealer Name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('company')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Dealer Company')
|
|
||||||
->example('Suresh Traders')
|
|
||||||
->label('Dealer Company')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('visit_plan_date')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Visit Plan Date')
|
|
||||||
->example('2026-07-20')
|
|
||||||
->label('Visit Plan Date'),
|
|
||||||
ImportColumn::make('organizer')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Organizer')
|
|
||||||
->example('Ramesh')
|
|
||||||
->label('Organizer'),
|
|
||||||
ImportColumn::make('employee_master_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Receipient Employee Code')
|
|
||||||
->example('RAS001234')
|
|
||||||
->label('Receipient Employee Code')
|
|
||||||
->relationship(resolveUsing: 'code')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('number_of_person')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Number Of Person')
|
|
||||||
->example('10')
|
|
||||||
->label('Number Of Person'),
|
|
||||||
ImportColumn::make('purpose_of_visit')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Purpose Of Visit')
|
|
||||||
->example('Meeting')
|
|
||||||
->label('Purpose Of Visit'),
|
|
||||||
ImportColumn::make('status')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Status')
|
|
||||||
->example('Planned/Completed')
|
|
||||||
->label('Status'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resolveRecord(): ?DealerVisitPlan
|
|
||||||
{
|
|
||||||
$warnMsg = [];
|
|
||||||
|
|
||||||
$user = null;
|
|
||||||
$dealerName = trim($this->data['name']);
|
|
||||||
$dealerCompany = trim($this->data['company']);
|
|
||||||
$visitPlanDt = trim($this->data['visit_plan_date']);
|
|
||||||
$organizer = trim($this->data['organizer']);
|
|
||||||
$employeeCode = trim($this->data['employee_master_id']);
|
|
||||||
$noOfPerson = trim($this->data['number_of_person']);
|
|
||||||
$purposeOfVisit = trim($this->data['purpose_of_visit']);
|
|
||||||
$status = trim($this->data['status']);
|
|
||||||
$user = Filament::auth()->user()->name;
|
|
||||||
|
|
||||||
if (Str::length($employeeCode) < 5) {
|
|
||||||
$warnMsg[] = 'Invalid receipient employee number found!';
|
|
||||||
}
|
|
||||||
if (! empty($warnMsg)) {
|
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
$employeeId = EmployeeMaster::where('code', $employeeCode)->first();
|
|
||||||
|
|
||||||
$eId = $employeeId->id;
|
|
||||||
|
|
||||||
DealerVisitPlan::updateOrCreate(
|
|
||||||
[
|
|
||||||
'name' => $dealerName,
|
|
||||||
'company' => $dealerCompany,
|
|
||||||
'visit_plan_date' => Carbon::createFromFormat('d-m-Y', $visitPlanDt)->format('Y-m-d'),
|
|
||||||
'organizer' => $organizer,
|
|
||||||
'employee_master_id' => $eId,
|
|
||||||
'number_of_person' => $noOfPerson,
|
|
||||||
'purpose_of_visit' => $purposeOfVisit,
|
|
||||||
'status' => $status,
|
|
||||||
'created_by' => $user,
|
|
||||||
'updated_by' => $user,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// return new DealerVisitPlan();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
|
||||||
{
|
|
||||||
$body = 'Your dealer visit plan import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
|
||||||
|
|
||||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
|
||||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource\Pages;
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource\RelationManagers;
|
|
||||||
use App\Models\DealerVisitPlan;
|
|
||||||
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 Filament\Tables\Actions\ExportAction;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use App\Filament\Exports\DealerVisitPlanExporter;
|
|
||||||
use App\Filament\Imports\DealerVisitPlanImporter;
|
|
||||||
|
|
||||||
class DealerVisitPlanResource extends Resource
|
|
||||||
{
|
|
||||||
protected static ?string $model = DealerVisitPlan::class;
|
|
||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Gate Entry';
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
|
||||||
{
|
|
||||||
return $form
|
|
||||||
->schema([
|
|
||||||
Forms\Components\TextInput::make('organizer')
|
|
||||||
->label('Organizer'),
|
|
||||||
Forms\Components\TextInput::make('mobile_number')
|
|
||||||
->label('Mobile Number'),
|
|
||||||
Forms\Components\TextInput::make('name')
|
|
||||||
->label('Dealer Name'),
|
|
||||||
Forms\Components\TextInput::make('company')
|
|
||||||
->label('Dealer Company'),
|
|
||||||
Forms\Components\DatePicker::make('visit_plan_date')
|
|
||||||
->label('Visit Plan Date'),
|
|
||||||
Forms\Components\Select::make('employee_master_id')
|
|
||||||
->label('Recipient Employee')
|
|
||||||
->relationship('employeeMaster', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\TextInput::make('number_of_person')
|
|
||||||
->label('Number Of Person'),
|
|
||||||
Forms\Components\TextInput::make('purpose_of_visit')
|
|
||||||
->label('Purpose Of Visit'),
|
|
||||||
Forms\Components\Select::make('mode_of_travel')
|
|
||||||
->label('Mode Of Travel')
|
|
||||||
->options([
|
|
||||||
'Rental' => 'Rental',
|
|
||||||
'Car' => 'Car',
|
|
||||||
'Bike' => 'Bike',
|
|
||||||
])
|
|
||||||
->reactive()
|
|
||||||
->placeholder('Select Mode of Travel'),
|
|
||||||
Forms\Components\Select::make('status')
|
|
||||||
->label('Status')
|
|
||||||
->options([
|
|
||||||
'Planned' => 'Planned',
|
|
||||||
'Completed' => 'Completed',
|
|
||||||
])
|
|
||||||
->required(),
|
|
||||||
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('name')
|
|
||||||
->label('Dealer Name')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('company')
|
|
||||||
->label('Dealer Company')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('visit_plan_date')
|
|
||||||
->label('Visit Plan Date')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->date()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('organizer')
|
|
||||||
->label('Organizer')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('mobile_number')
|
|
||||||
->label('Mobile Number')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('employeeMaster.name')
|
|
||||||
->label('Recipient Employee')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('number_of_person')
|
|
||||||
->label('No of Person')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('purpose_of_visit')
|
|
||||||
->label('Purpose of Visit')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('mode_of_travel')
|
|
||||||
->label('Mode of travel')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('status')
|
|
||||||
->label('Status')
|
|
||||||
->alignCenter()
|
|
||||||
->searchable()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
|
||||||
->dateTime()
|
|
||||||
->sortable()
|
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
Tables\Columns\TextColumn::make('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(),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
->headerActions([
|
|
||||||
ImportAction::make()
|
|
||||||
->label('Import Dealer Visit Plan')
|
|
||||||
->color('warning')
|
|
||||||
->importer(DealerVisitPlanImporter::class)
|
|
||||||
->visible(function () {
|
|
||||||
return Filament::auth()->user()->can('view import dealer visit plan');
|
|
||||||
}),
|
|
||||||
ExportAction::make()
|
|
||||||
->label('Export Dealer Visit Plan')
|
|
||||||
->color('warning')
|
|
||||||
->exporter(DealerVisitPlanExporter::class)
|
|
||||||
->visible(function () {
|
|
||||||
return Filament::auth()->user()->can('view export dealer visit plan');
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getRelations(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPages(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'index' => Pages\ListDealerVisitPlans::route('/'),
|
|
||||||
'create' => Pages\CreateDealerVisitPlan::route('/create'),
|
|
||||||
'view' => Pages\ViewDealerVisitPlan::route('/{record}'),
|
|
||||||
'edit' => Pages\EditDealerVisitPlan::route('/{record}/edit'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getEloquentQuery(): Builder
|
|
||||||
{
|
|
||||||
return parent::getEloquentQuery()
|
|
||||||
->withoutGlobalScopes([
|
|
||||||
SoftDeletingScope::class,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
|
||||||
|
|
||||||
class CreateDealerVisitPlan extends CreateRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DealerVisitPlanResource::class;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\EditRecord;
|
|
||||||
|
|
||||||
class EditDealerVisitPlan extends EditRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DealerVisitPlanResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\ViewAction::make(),
|
|
||||||
Actions\DeleteAction::make(),
|
|
||||||
Actions\ForceDeleteAction::make(),
|
|
||||||
Actions\RestoreAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
|
||||||
|
|
||||||
class ListDealerVisitPlans extends ListRecords
|
|
||||||
{
|
|
||||||
protected static string $resource = DealerVisitPlanResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\CreateAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Resources\DealerVisitPlanResource\Pages;
|
|
||||||
|
|
||||||
use App\Filament\Resources\DealerVisitPlanResource;
|
|
||||||
use Filament\Actions;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
|
||||||
|
|
||||||
class ViewDealerVisitPlan extends ViewRecord
|
|
||||||
{
|
|
||||||
protected static string $resource = DealerVisitPlanResource::class;
|
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Actions\EditAction::make(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ 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;
|
||||||
@@ -29,7 +28,6 @@ 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
|
||||||
{
|
{
|
||||||
@@ -97,13 +95,11 @@ 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
|
||||||
@@ -113,92 +109,6 @@ 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')
|
||||||
@@ -238,8 +148,7 @@ class VisitorEntryResource extends Resource
|
|||||||
'Supplier' => 'Supplier',
|
'Supplier' => 'Supplier',
|
||||||
'InterUnitStaff' => 'Inter Unit Staff',
|
'InterUnitStaff' => 'Inter Unit Staff',
|
||||||
'InterviewCandidates' => 'Interview Candidates',
|
'InterviewCandidates' => 'Interview Candidates',
|
||||||
'Customers' => 'Customers',
|
'Customers/Dealers' => 'Customers/Dealers',
|
||||||
'Dealers' => 'Dealers',
|
|
||||||
'Bankers' => 'Bankers',
|
'Bankers' => 'Bankers',
|
||||||
'ServiceProviders' => 'Service Providers',
|
'ServiceProviders' => 'Service Providers',
|
||||||
'GovermentOfficials' => 'Government Officials',
|
'GovermentOfficials' => 'Government Officials',
|
||||||
@@ -362,8 +271,6 @@ 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'),
|
||||||
@@ -410,13 +317,8 @@ 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('Mobile Number')
|
->label('Visitor Mobile Number')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
|||||||
@@ -3,10 +3,8 @@
|
|||||||
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;
|
||||||
@@ -141,18 +139,6 @@ 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
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
||||||
|
|
||||||
class DealerVisitPlan extends Model
|
|
||||||
{
|
|
||||||
use SoftDeletes;
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'employee_master_id',
|
|
||||||
'name',
|
|
||||||
'company',
|
|
||||||
'visit_plan_date',
|
|
||||||
'organizer',
|
|
||||||
'mobile_number',
|
|
||||||
'number_of_person',
|
|
||||||
'purpose_of_visit',
|
|
||||||
'mode_of_travel',
|
|
||||||
'status',
|
|
||||||
'created_by',
|
|
||||||
'updated_by',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function employeeMaster(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(EmployeeMaster::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ class VisitorEntry extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'mobile_number',
|
'mobile_number',
|
||||||
'organizer',
|
|
||||||
'register_id',
|
'register_id',
|
||||||
'name',
|
'name',
|
||||||
'company',
|
'company',
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Policies;
|
|
||||||
|
|
||||||
use Illuminate\Auth\Access\Response;
|
|
||||||
use App\Models\DealerVisitPlan;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class DealerVisitPlanPolicy
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Determine whether the user can view any models.
|
|
||||||
*/
|
|
||||||
public function viewAny(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('view-any DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can view the model.
|
|
||||||
*/
|
|
||||||
public function view(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('view DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can create models.
|
|
||||||
*/
|
|
||||||
public function create(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('create DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can update the model.
|
|
||||||
*/
|
|
||||||
public function update(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('update DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can delete the model.
|
|
||||||
*/
|
|
||||||
public function delete(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('delete DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can delete any models.
|
|
||||||
*/
|
|
||||||
public function deleteAny(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('delete-any DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can restore the model.
|
|
||||||
*/
|
|
||||||
public function restore(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('restore DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can restore any models.
|
|
||||||
*/
|
|
||||||
public function restoreAny(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('restore-any DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can replicate the model.
|
|
||||||
*/
|
|
||||||
public function replicate(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('replicate DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can reorder the models.
|
|
||||||
*/
|
|
||||||
public function reorder(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('reorder DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can permanently delete the model.
|
|
||||||
*/
|
|
||||||
public function forceDelete(User $user, DealerVisitPlan $dealervisitplan): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('force-delete DealerVisitPlan');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine whether the user can permanently delete any models.
|
|
||||||
*/
|
|
||||||
public function forceDeleteAny(User $user): bool
|
|
||||||
{
|
|
||||||
return $user->checkPermissionTo('force-delete-any DealerVisitPlan');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"alperenersoy/filament-export": "^3.0",
|
"alperenersoy/filament-export": "^3.0",
|
||||||
"althinect/filament-spatie-roles-permissions": "^2.3",
|
"althinect/filament-spatie-roles-permissions": "^4.0",
|
||||||
"diogogpinto/filament-auth-ui-enhancer": "^1.0",
|
"diogogpinto/filament-auth-ui-enhancer": "^1.0",
|
||||||
"erag/laravel-pwa": "^1.9",
|
"erag/laravel-pwa": "^1.9",
|
||||||
"filament/filament": "^3.3",
|
"filament/filament": "^3.3",
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
<?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 dealer_visit_plans (
|
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
|
||||||
|
|
||||||
employee_master_id BIGINT NOT NULL,
|
|
||||||
|
|
||||||
name TEXT DEFAULT NULL,
|
|
||||||
company TEXT DEFAULT NULL,
|
|
||||||
visit_plan_date DATE DEFAULT NULL,
|
|
||||||
organizer TEXT DEFAULT NULL,
|
|
||||||
mobile_number TEXT DEFAULT NULL,
|
|
||||||
number_of_person TEXT DEFAULT NULL,
|
|
||||||
purpose_of_visit TEXT DEFAULT NULL,
|
|
||||||
mode_of_travel TEXT DEFAULT NULL,
|
|
||||||
status TEXT DEFAULT NULL,
|
|
||||||
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
updated_at TIMESTAMP,
|
|
||||||
deleted_at TIMESTAMP,
|
|
||||||
|
|
||||||
created_by TEXT NULL,
|
|
||||||
updated_by TEXT NULL,
|
|
||||||
|
|
||||||
FOREIGN KEY (employee_master_id) REFERENCES employee_masters (id)
|
|
||||||
);
|
|
||||||
SQL;
|
|
||||||
|
|
||||||
DB::statement($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('dealer_visit_plans');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
<?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
|
|
||||||
{
|
|
||||||
$sql3 = <<<'SQL'
|
|
||||||
ALTER TABLE visitor_entries
|
|
||||||
ADD COLUMN organizer TEXT DEFAULT NULL
|
|
||||||
SQL;
|
|
||||||
|
|
||||||
DB::statement($sql3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
// Schema::table('visitor_entries', function (Blueprint $table) {
|
|
||||||
// //
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user