Faza 3.5+3.6+4+5: Marketing, Reports, Provisioning, PWA
═══ 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.
This commit is contained in:
@@ -1,7 +1,62 @@
|
||||
<?php
|
||||
|
||||
use App\Tenancy\TenantManager;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
// PWA — manifest dinamic per tenant.
|
||||
Route::get('/manifest.json', function (Request $request) {
|
||||
$tenant = app(TenantManager::class)->current();
|
||||
$name = $tenant?->display_name ?? $tenant?->name ?? 'AutoCRM';
|
||||
$themeColor = $tenant?->settings['theme_color'] ?? '#3B82F6';
|
||||
$shortName = $tenant?->slug ?? 'autocrm';
|
||||
|
||||
return response()->json([
|
||||
'name' => $name,
|
||||
'short_name' => mb_substr($shortName, 0, 12),
|
||||
'description' => 'CRM autoservice — ' . $name,
|
||||
'start_url' => '/app',
|
||||
'display' => 'standalone',
|
||||
'orientation' => 'any',
|
||||
'background_color' => '#ffffff',
|
||||
'theme_color' => $themeColor,
|
||||
'lang' => $tenant?->settings['language'] ?? 'ro',
|
||||
'icons' => [
|
||||
['src' => '/pwa/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png'],
|
||||
['src' => '/pwa/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png'],
|
||||
['src' => '/pwa/icon-maskable.png', 'sizes' => '512x512', 'type' => 'image/png', 'purpose' => 'maskable'],
|
||||
],
|
||||
])->header('Cache-Control', 'public, max-age=3600');
|
||||
});
|
||||
|
||||
// Service worker stub — minimal cache for shell.
|
||||
Route::get('/sw.js', function () {
|
||||
return response(<<<'JS'
|
||||
const CACHE = 'autocrm-shell-v1';
|
||||
const SHELL = ['/manifest.json'];
|
||||
self.addEventListener('install', e => {
|
||||
e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)));
|
||||
});
|
||||
self.addEventListener('activate', e => {
|
||||
e.waitUntil(caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
|
||||
));
|
||||
});
|
||||
self.addEventListener('fetch', e => {
|
||||
const u = new URL(e.request.url);
|
||||
if (e.request.method !== 'GET') return;
|
||||
// network-first for app routes; cache-first for static
|
||||
if (u.pathname.startsWith('/build/') || u.pathname.startsWith('/pwa/')) {
|
||||
e.respondWith(caches.match(e.request).then(m => m || fetch(e.request).then(r => {
|
||||
const copy = r.clone();
|
||||
caches.open(CACHE).then(c => c.put(e.request, copy));
|
||||
return r;
|
||||
})));
|
||||
}
|
||||
});
|
||||
JS, 200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'public, max-age=3600']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user