Files
autocrm/app/Filament/Tenant/Pages/Integrations.php
T
Vasyka 29e5481fc3 refactor(nav): collapse single-item groups + fix ungrouped CRM resources
Previously nav had 12 groups, several with just 1 item. Now 8 clean
groups, no orphans:

- Anvelope (1 item) → merged into Service (Seturi anvelope)
- Stoc & Finanțe (1 item) → merged into Depozit (Import factură Excel)
- Tinichigerie (1 item) → merged into Service (Tinichigerie / Detailing)
- Subcontractare (2 items) → merged into Service (Lucrări terți,
  Subcontractori)
- Integrări moved from Marketing → Admin (it's a config concern, not
  a marketing feature)
- ClientResource + VehicleResource were ungrouped → added to CRM

Final groups:
  Admin(8) · Analiză(4) · CRM(5) · Depozit(10) · Finanțe(6) ·
  Magazin(2) · Marketing(3) · Service(11)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-08-10 19:29:03 +00:00

131 lines
4.7 KiB
PHP

<?php
namespace App\Filament\Tenant\Pages;
use App\Tenancy\TenantManager;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
class Integrations extends Page
{
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-puzzle-piece';
public static function getNavigationLabel(): string
{
return __('nav.label.Integrări');
}
public static function getNavigationGroup(): ?string
{
return __('nav.group.Admin');
}
protected static ?int $navigationSort = 63;
protected static ?string $title = null;
public function getTitle(): string
{
return __('Integrări externe');
}
protected string $view = 'filament.tenant.pages.integrations';
public array $config = [];
public function mount(): void
{
$tenant = app(TenantManager::class)->current();
$this->config = (array) ($tenant?->settings['integrations'] ?? []);
}
public function setStatus(string $key, bool $enabled): void
{
$this->config[$key]['enabled'] = $enabled;
$this->save();
}
public function updateField(string $key, string $field, ?string $value): void
{
$this->config[$key][$field] = $value;
}
public function save(): void
{
$tenant = app(TenantManager::class)->current();
if (! $tenant) return;
$tenant->update([
'settings' => array_merge((array) $tenant->settings, [
'integrations' => $this->config,
]),
]);
Notification::make()->title(__('Integrări salvate'))->success()->send();
}
public function integrations(): array
{
return [
'telegram_bot' => [
'name' => 'Telegram Bot',
'icon' => '✈️',
'color' => '#229ED9',
'description' => __('Primește cereri din canalul Telegram + trimite confirmări automate.'),
'fields' => [
'bot_token' => ['label' => 'Bot Token', 'type' => 'password', 'placeholder' => 'din @BotFather'],
'chat_id' => ['label' => 'Channel/Chat ID', 'type' => 'text', 'placeholder' => '@psauto_md'],
],
],
'whatsapp_business' => [
'name' => 'WhatsApp Business',
'icon' => '💬',
'color' => '#25D366',
'description' => __('Trimite mesaje template către clienți (programări, confirmări).'),
'fields' => [
'phone_id' => ['label' => 'Phone Number ID', 'type' => 'text'],
'token' => ['label' => 'Permanent Access Token', 'type' => 'password'],
],
],
'google_ads' => [
'name' => 'Google Ads',
'icon' => '🔍',
'color' => '#EA4335',
'description' => 'Tracking conversii — leadurile generate de campanii Google.',
'fields' => [
'customer_id' => ['label' => 'Customer ID', 'type' => 'text', 'placeholder' => '123-456-7890'],
'conversion_id' => ['label' => 'Conversion ID', 'type' => 'text'],
],
],
'facebook' => [
'name' => 'Facebook / Instagram Lead Ads',
'icon' => '📘',
'color' => '#1877F2',
'description' => __('Importă lead-uri direct din Lead Ads forms.'),
'fields' => [
'page_id' => ['label' => 'Page ID', 'type' => 'text'],
'access_token' => ['label' => 'Access Token', 'type' => 'password'],
],
],
'sms_gateway' => [
'name' => 'SMS Gateway',
'icon' => '📱',
'color' => '#6366F1',
'description' => __('Trimite SMS-uri prin gateway local (Moldcell/Orange API).'),
'fields' => [
'provider' => ['label' => 'Provider', 'type' => 'text', 'placeholder' => 'moldcell / orange / twilio'],
'api_key' => ['label' => 'API Key', 'type' => 'password'],
'sender_id' => ['label' => 'Sender ID', 'type' => 'text'],
],
],
'webhook_in' => [
'name' => __('Webhook intrări (formulare site)'),
'icon' => '🪝',
'color' => '#8B5CF6',
'description' => __('URL secret pentru POST direct cu lead-uri din site-ul tău.'),
'fields' => [
'secret' => ['label' => 'Secret token', 'type' => 'text', 'placeholder' => 'random string'],
],
],
];
}
}