174 lines
12 KiB
PHP
174 lines
12 KiB
PHP
<div class="space-y-6">
|
|
<!-- Add Currency Button -->
|
|
<div class="flex justify-end">
|
|
<button type="button" onclick="document.getElementById('addCurrencyModal').classList.remove('hidden')"
|
|
class="inline-flex items-center gap-2 px-4 py-2 bg-teal-600 text-white text-sm font-medium rounded-lg hover:bg-teal-700 transition-colors">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/></svg>
|
|
{{ __('settings.add_currency') }}
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Currencies Table -->
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50 border-b border-gray-200">
|
|
<tr>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('settings.currency_code') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('settings.currency_name') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('settings.currency_symbol') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('settings.exchange_rate') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('settings.decimal_places') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('common.status') }}</th>
|
|
<th class="px-4 py-3 text-start text-xs font-medium text-gray-500">{{ __('common.actions') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
@forelse($allCurrencies as $currency)
|
|
<tr class="hover:bg-gray-50 transition-colors">
|
|
<td class="px-4 py-3 text-sm font-medium text-gray-900" dir="ltr">{{ $currency->code }}</td>
|
|
<td class="px-4 py-3 text-sm text-gray-700">{{ $currency->name }}</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">{{ $currency->symbol }}</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600" dir="ltr">{{ number_format($currency->exchange_rate_to_usd, 4) }}</td>
|
|
<td class="px-4 py-3 text-sm text-gray-600">{{ persian_num($currency->decimal_places) }}</td>
|
|
<td class="px-4 py-3">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium
|
|
{{ $currency->is_active ? 'bg-emerald-50 text-emerald-700' : 'bg-red-50 text-red-700' }}">
|
|
{{ $currency->is_active ? __('settings.active') : __('settings.inactive') }}
|
|
</span>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center gap-2">
|
|
<button type="button" onclick="editCurrency({{ $currency->id }}, '{{ $currency->code }}', '{{ $currency->name }}', '{{ $currency->symbol }}', {{ $currency->decimal_places }}, {{ $currency->exchange_rate_to_usd }})"
|
|
class="px-2 py-1 text-xs font-medium text-teal-700 bg-teal-50 rounded hover:bg-teal-100 transition-colors">
|
|
{{ __('common.edit') }}
|
|
</button>
|
|
<form method="POST" action="{{ route('settings.currencies.toggle', $currency) }}" class="inline">
|
|
@csrf @method('PATCH')
|
|
<button type="submit"
|
|
class="px-2 py-1 text-xs font-medium {{ $currency->is_active ? 'text-red-700 bg-red-50 hover:bg-red-100' : 'text-emerald-700 bg-emerald-50 hover:bg-emerald-100' }} rounded transition-colors">
|
|
{{ $currency->is_active ? __('settings.deactivate') : __('settings.activate') }}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="text-center py-8 text-gray-400">{{ __('settings.no_currencies') }}</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Currency Modal -->
|
|
<div id="addCurrencyModal" class="hidden fixed inset-0 z-50 overflow-y-auto">
|
|
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20">
|
|
<div class="fixed inset-0 bg-gray-900/50 transition-opacity" onclick="document.getElementById('addCurrencyModal').classList.add('hidden')"></div>
|
|
<div class="relative bg-white rounded-xl shadow-xl max-w-md w-full p-6 z-10">
|
|
<h3 class="text-lg font-bold text-gray-900 mb-4">{{ __('settings.add_currency') }}</h3>
|
|
<form method="POST" action="{{ route('settings.currencies.store') }}" class="space-y-4">
|
|
@csrf
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_code') }}</label>
|
|
<input type="text" name="code" required maxlength="10" dir="ltr"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500"
|
|
placeholder="USD">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_name') }}</label>
|
|
<input type="text" name="name" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_symbol') }}</label>
|
|
<input type="text" name="symbol" required maxlength="10"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.decimal_places') }}</label>
|
|
<input type="number" name="decimal_places" required min="0" max="6" value="0"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.exchange_rate') }}</label>
|
|
<input type="number" name="exchange_rate_to_usd" required min="0" step="0.0001"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500" dir="ltr">
|
|
<p class="text-xs text-gray-400 mt-1">{{ __('settings.exchange_rate_help') }}</p>
|
|
</div>
|
|
<div class="flex justify-end gap-3 pt-2">
|
|
<button type="button" onclick="document.getElementById('addCurrencyModal').classList.add('hidden')"
|
|
class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors">
|
|
{{ __('common.cancel') }}
|
|
</button>
|
|
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700 transition-colors">
|
|
{{ __('common.create') }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit Currency Modal -->
|
|
<div id="editCurrencyModal" class="hidden fixed inset-0 z-50 overflow-y-auto">
|
|
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20">
|
|
<div class="fixed inset-0 bg-gray-900/50 transition-opacity" onclick="document.getElementById('editCurrencyModal').classList.add('hidden')"></div>
|
|
<div class="relative bg-white rounded-xl shadow-xl max-w-md w-full p-6 z-10">
|
|
<h3 class="text-lg font-bold text-gray-900 mb-4">{{ __('settings.edit_currency') }}</h3>
|
|
<form id="editCurrencyForm" method="POST" action="" class="space-y-4">
|
|
@csrf @method('PUT')
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_code') }}</label>
|
|
<input type="text" id="edit_currency_code" disabled dir="ltr"
|
|
class="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_name') }}</label>
|
|
<input type="text" name="name" id="edit_currency_name" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.currency_symbol') }}</label>
|
|
<input type="text" name="symbol" id="edit_currency_symbol" required maxlength="10"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.decimal_places') }}</label>
|
|
<input type="number" name="decimal_places" id="edit_currency_decimal" required min="0" max="6"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('settings.exchange_rate') }}</label>
|
|
<input type="number" name="exchange_rate_to_usd" id="edit_currency_rate" required min="0" step="0.0001"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500" dir="ltr">
|
|
</div>
|
|
<div class="flex justify-end gap-3 pt-2">
|
|
<button type="button" onclick="document.getElementById('editCurrencyModal').classList.add('hidden')"
|
|
class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors">
|
|
{{ __('common.cancel') }}
|
|
</button>
|
|
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700 transition-colors">
|
|
{{ __('common.save_changes') }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script>
|
|
function editCurrency(id, code, name, symbol, decimalPlaces, rate) {
|
|
document.getElementById('editCurrencyForm').action = '{{ route("settings.currencies.update", ["currency" => "__ID__"]) }}'.replace('__ID__', id);
|
|
document.getElementById('edit_currency_code').value = code;
|
|
document.getElementById('edit_currency_name').value = name;
|
|
document.getElementById('edit_currency_symbol').value = symbol;
|
|
document.getElementById('edit_currency_decimal').value = decimalPlaces;
|
|
document.getElementById('edit_currency_rate').value = rate;
|
|
document.getElementById('editCurrencyModal').classList.remove('hidden');
|
|
}
|
|
</script>
|
|
@endpush
|