8d82af2f54
═══ Faza 3.5: Marketing ═══
Schema: msg_templates, marketing_channels, calls
Modele cu logică:
- MessageTemplate::render($context) — substituie {key} tokens
- MarketingChannel: roi/conversion_rate/cost_per_lead computed attrs
- Call: duration_formatted helper
Resources Filament (group Marketing):
- MessageTemplateResource: 5 canale (telegram/whatsapp/viber/sms/email)
- MarketingChannelResource: budget vs revenue cu ROI live calculat
- CallResource: in/out/missed cu filtre azi/missed
═══ Faza 3.6: Analytics ═══
Custom Filament Page Reports cu 6 rapoarte tab-uite:
- Finanțe: încasări/cheltuieli/profit/datorii + breakdown pe metodă/categorie
- Încărcare: fișe deschise/închise + breakdown pe status
- Mecanici: ore lucrate, manopere, venit per mecanic
- Manopere top: cele mai frecvente cu nr/ore/venit
- Piese: top vândute + low-stock
- Clienți: noi în perioadă + lead-uri pe sursă
Selector perioadă: azi / săptămâna / luna / luna trecută / anul
═══ Faza 4: Central provisioning ═══
- CoolifyClient service (Coolify v4 REST API wrapper)
- CompanyProvisioner: creează Company + admin user + roles + adaugă
subdomeniul în Coolify FQDN + trigger redeploy automat
- CreateCompany page override → folosește provisioner, returnează
notificare cu credentialele admin
- Form CompanyResource extins cu admin_name/email/password (vizibil doar create)
- Action 'Suspendă' / 'Activează' pe table cu confirmation
Env vars necesare în Coolify pentru provisioning auto:
COOLIFY_API_URL=http://65.21.20.141:8000
COOLIFY_API_TOKEN=<token>
COOLIFY_APP_UUID=g13hlrpd5g44zxl5af3ktio2
═══ Faza 5: PWA + branding ═══
- Route /manifest.json dinamic per tenant (nume, theme color, icons)
- Route /sw.js — service worker minimal (cache shell + static)
- TenantPanelProvider renderHook HEAD_END — link manifest + theme-color
+ apple-mobile-web-app meta
- TenantPanelProvider renderHook BODY_END — registrare service worker
Seed extins:
- 5 template-uri mesaje (programare/auto-gata/reminder/ITP/felicitare)
- 5 canale marketing (Google Ads/FB/IG/Telegram/Recomandări)
- 2 apeluri demo
Total Filament tenant routes: 81.
99 lines
4.4 KiB
PHP
99 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources;
|
|
|
|
use App\Filament\Tenant\Resources\MarketingChannelResource\Pages;
|
|
use App\Models\Tenant\MarketingChannel;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class MarketingChannelResource extends Resource
|
|
{
|
|
protected static ?string $model = MarketingChannel::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-megaphone';
|
|
|
|
protected static ?string $navigationLabel = 'Canale marketing';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Marketing';
|
|
|
|
protected static ?string $modelLabel = 'canal';
|
|
|
|
protected static ?string $pluralModelLabel = 'canale marketing';
|
|
|
|
protected static ?int $navigationSort = 61;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Schemas\Components\Section::make('Identificare')
|
|
->columns(3)
|
|
->schema([
|
|
Forms\Components\TextInput::make('name')->label('Nume canal')->required()->maxLength(120),
|
|
Forms\Components\TextInput::make('icon')->label('Iconiță (emoji)')->maxLength(8)->placeholder('🔍 / 📘 / 📸'),
|
|
Forms\Components\ColorPicker::make('color'),
|
|
]),
|
|
Schemas\Components\Section::make('Buget & rezultate (luna curentă)')
|
|
->columns(3)
|
|
->schema([
|
|
Forms\Components\TextInput::make('budget_monthly')->label('Buget')->numeric()->default(0),
|
|
Forms\Components\TextInput::make('spent_monthly')->label('Cheltuit')->numeric()->default(0),
|
|
Forms\Components\TextInput::make('revenue')->label('Venit generat')->numeric()->default(0),
|
|
Forms\Components\TextInput::make('leads_count')->label('Lead-uri')->numeric()->default(0),
|
|
Forms\Components\TextInput::make('converted_count')->label('Convertite')->numeric()->default(0),
|
|
Forms\Components\Toggle::make('is_active')->label('Activ')->default(true),
|
|
]),
|
|
Forms\Components\Textarea::make('notes')->label('Observații')->columnSpanFull()->rows(2),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\ColorColumn::make('color')->label(''),
|
|
Tables\Columns\TextColumn::make('icon')->label('')->width(40),
|
|
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
|
|
Tables\Columns\TextColumn::make('budget_monthly')->label('Buget')->money('MDL')->alignRight(),
|
|
Tables\Columns\TextColumn::make('spent_monthly')->label('Cheltuit')->money('MDL')->alignRight(),
|
|
Tables\Columns\TextColumn::make('leads_count')->label('Lead-uri')->alignRight(),
|
|
Tables\Columns\TextColumn::make('converted_count')->label('Convertite')->alignRight(),
|
|
Tables\Columns\TextColumn::make('revenue')->label('Venit')->money('MDL')->alignRight()->color('success'),
|
|
Tables\Columns\TextColumn::make('roi')
|
|
->label('ROI')
|
|
->state(fn (MarketingChannel $r) => $r->roi)
|
|
->formatStateUsing(fn ($s) => $s . '%')
|
|
->color(fn ($s) => $s >= 0 ? 'success' : 'danger')
|
|
->alignRight(),
|
|
Tables\Columns\TextColumn::make('cost_per_lead')
|
|
->label('Cost/lead')
|
|
->state(fn (MarketingChannel $r) => $r->cost_per_lead)
|
|
->money('MDL')
|
|
->alignRight(),
|
|
Tables\Columns\IconColumn::make('is_active')->boolean(),
|
|
])
|
|
->filters([
|
|
Tables\Filters\TernaryFilter::make('is_active')->label('Active'),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->defaultSort('revenue', 'desc');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListMarketingChannels::route('/'),
|
|
'create' => Pages\CreateMarketingChannel::route('/create'),
|
|
'edit' => Pages\EditMarketingChannel::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|