@extends('layouts.app')
@section('title', __('dashboard.sidebar_settings'))
@section('page_heading', __('dashboard.sidebar_settings'))
@section('content')
@php
$s = fn($key) => $settings->where('key',$key)->first();
$sv = fn($key) => $settings->where('key',$key)->first()?->value ?? '';
@endphp
{{-- Navigation --}}
@foreach([
['dashboard.settings.general', 'general', 'fa-solid fa-sliders', __('dashboard.General Settings')],
['dashboard.settings.email', 'email', 'fa-solid fa-envelope-open-text', __('dashboard.Email Settings')],
['dashboard.settings.invoice', 'invoice', 'fa-solid fa-receipt', 'إعدادات الفاتورة'],
] as [$route,$t,$icon,$label])
@if(Route::has($route))
{{ $label }}
@endif
@endforeach
@if($type === 'general')
@php
$lang = $sv('default_language') ?: '—';
$tz = $sv('timezone') ?: '—';
$currency = $sv('system_currency') ?: '—';
@endphp
{{-- KPIs --}}
@foreach([
['fa-solid fa-language', '#eff6ff', '#2563eb', $lang, 'اللغة الافتراضية'],
['fa-solid fa-clock-rotate-left', '#f0fdf4', '#16a34a', $tz, 'المنطقة الزمنية'],
['fa-solid fa-coins', '#fffbeb', '#d97706', $currency, 'عملة النظام'],
['fa-solid fa-database', '#f8fafc', '#64748b', $settings->count(), 'إجمالي الإعدادات'],
] as [$ico,$bg,$color,$val,$lbl])
@endforeach
@elseif($type === 'email')
@php
$mailHost = $sv('smtp_host') ?: '—';
$mailPort = $sv('smtp_port') ?: '—';
$mailEncryption = strtoupper($sv('smtp_encryption') ?: '—');
$mailFrom = $sv('mail_from_address') ?: '—';
@endphp
{{-- KPIs --}}
@foreach([
['fa-solid fa-network-wired', '#eff6ff', '#2563eb', $mailHost, 'خادم SMTP'],
['fa-solid fa-plug', '#f0fdf4', '#16a34a', $mailPort, 'المنفذ'],
['fa-solid fa-shield-halved', '#fffbeb', '#d97706', $mailEncryption, 'التشفير'],
['fa-solid fa-envelope', '#fef2f2', '#dc2626', $mailFrom, 'بريد المرسل'],
] as [$ico,$bg,$color,$val,$lbl])
@endforeach
{{-- SMTP form --}}
@csrf
@foreach([
['mail_mailer', 'نوع المحرك (Mailer)', 'text'],
['smtp_host', 'خادم SMTP (Host)', 'text'],
['smtp_port', 'المنفذ (Port)', 'number'],
['smtp_username', 'اسم المستخدم', 'text'],
['mail_from_address', 'إيميل المرسل', 'email'],
['mail_from_name', 'اسم المرسل', 'text'],
] as [$key,$lbl,$inputType])
@php $setting = $s($key); @endphp
@if($setting)
{{ $lbl }}
value) }}">
@error("settings.{$key}.value")
{{ $message }}
@enderror
@endif
@endforeach
{{-- Encryption select --}}
@php $encSetting = $s('smtp_encryption'); @endphp
@if($encSetting)
التشفير
@foreach(['ssl'=>'SSL','tls'=>'TLS','none'=>'بدون تشفير'] as $v=>$l)
value)===$v)>{{ $l }}
@endforeach
@endif
{{-- Password --}}
@php $passSetting = $s('smtp_password'); @endphp
@if($passSetting)
@endif
{{ __('dashboard.Save Settings') }}
{{-- Test email --}}
@csrf
{{ __('dashboard.Enter email for testing') }}
@error('test_email')
{{ $message }}
@enderror
{{ __('dashboard.Send Test') }}
{{-- Tips --}}
@elseif($type === 'invoice')
@csrf
{{-- Identity sidebar --}}
{{-- Content --}}
@foreach(['invoice_phone'=>'رقم الهاتف','invoice_email'=>'البريد الإلكتروني','invoice_prefix'=>'بادئة رقم الفاتورة','invoice_footer'=>'نص التذييل'] as $key=>$lbl)
@php $setting = $s($key); @endphp
@if($setting)
{{ $lbl }}
value) }}">
@endif
@endforeach
@foreach(['invoice_iban'=>'رقم الآيبان (IBAN)','invoice_address'=>'العنوان','invoice_receipt_acknowledgment'=>'نص إقرار الاستلام','invoice_terms'=>'الشروط والأحكام'] as $key=>$lbl)
@php $setting = $s($key); @endphp
@if($setting)
{{ $lbl }}
{{ old("settings.{$key}.value",$setting->value) }}
@endif
@endforeach
{{-- Toggles --}}
@foreach(['show_tax_number_on_invoice'=>'إظهار الرقم الضريبي','show_cr_number_on_invoice'=>'إظهار السجل التجاري','show_email_on_invoice'=>'إظهار البريد','show_address_on_invoice'=>'إظهار العنوان'] as $key=>$lbl)
@php $setting = $s($key); @endphp
@if($setting)
{{ $lbl }}
value)==='1') class="settings-toggle__input">
@endif
@endforeach
@endif
@endsection