Files
dockerfluxodecaixapro/modules/company/views/admin/form.twig
T
2026-09-01 10:46:29 -03:00

296 lines
19 KiB
Twig
Executable File

{% extends "layouts/dashboard.twig" %}
{% block title %}{{ title }} - {{ platformName }}{% endblock %}
{% block content %}
<div class="container-fluid px-4">
<h1 class="mt-4">{{ title }}</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="{{ url('admin/dashboard') }}">{{ __('dashboard.dashboard') }}</a></li>
<li class="breadcrumb-item"><a href="{{ url('admin/companies') }}">{{ __('company.title') }}</a></li>
<li class="breadcrumb-item active">{{ target_company ? __('company.edit_title') : __('company.create_title') }}</li>
</ol>
<div class="card mb-4">
<div class="card-header">
<i class="bi bi-building me-1"></i>
{{ __('company.details_title') }}
</div>
<div class="card-body">
{% if error %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %}
<form action="{{ target_company ? url('admin/companies/' ~ target_company.bus_id) : url('admin/companies') }}" method="POST" enctype="multipart/form-data">
{% if target_company %}
<input type="hidden" name="_method" value="PUT">
{% endif %}
{{ csrf_field()|raw }}
<div class="mb-3">
<label for="name" class="form-label">{{ __('company.company_name') }}</label>
<input type="text" class="form-control" id="name" name="name" value="{{ target_company ? target_company.bus_name : '' }}" required>
</div>
<div class="mb-3">
<label for="email" class="form-label">{{ __('company.email') }}</label>
<input type="email" class="form-control" id="email" name="email" value="{{ target_company ? target_company.bus_email : '' }}" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">{{ __('company.description') }}</label>
<div id="quill-editor" style="height: 300px;" data-target="description">{{ target_company ? target_company.bus_description|raw : '' }}</div>
<textarea class="form-control" id="description" name="description" style="display:none">{{ target_company ? target_company.bus_description : '' }}</textarea>
</div>
<div class="mb-3">
<label for="phone" class="form-label">{{ __('company.phone') }}</label>
<input type="text" class="form-control" id="phone" name="phone" value="{{ target_company ? target_company.bus_phone : '' }}">
</div>
<div class="mb-3">
<label for="website" class="form-label">{{ __('company.website') }}</label>
<input type="url" class="form-control" id="website" name="website" value="{{ target_company ? target_company.bus_website : '' }}">
</div>
<div class="mb-3">
<label for="tax_id" class="form-label">{{ __('company.tax_id') }}</label>
<input type="text" class="form-control" id="tax_id" name="tax_id" value="{{ target_company ? target_company.bus_tax_id : '' }}">
</div>
<div class="mb-3">
<label for="bus_type" class="form-label">{{ __('company.business_type') }}</label>
<select class="form-select" id="bus_type" name="bus_type">
<option value="individual" {{ target_company and target_company.bus_type == 'individual' ? 'selected' : '' }}>{{ __('company.individual') }}</option>
<option value="business" {{ target_company and target_company.bus_type == 'business' ? 'selected' : '' }}>{{ __('company.business') }}</option>
<option value="nonprofit" {{ target_company and target_company.bus_type == 'nonprofit' ? 'selected' : '' }}>{{ __('company.nonprofit') }}</option>
</select>
</div>
<div class="mb-3">
<label for="status" class="form-label">{{ __('company.status') }}</label>
<select class="form-select" id="status" name="status">
<option value="active" {{ target_company and target_company.bus_status == 'active' ? 'selected' : '' }}>{{ __('company.active') }}</option>
<option value="inactive" {{ target_company and target_company.bus_status == 'inactive' ? 'selected' : '' }}>{{ __('company.inactive') }}</option>
</select>
</div>
{% if user.isSuperAdmin() or target_company and target_company.bus_id == 1 %}
<div class="card mb-3 border-warning">
<div class="card-header bg-warning text-dark">
<i class="bi bi-globe me-1"></i> {{ __('company.platform_config_title') }}
</div>
<div class="card-body">
<div class="mb-3">
<label for="platform_name" class="form-label">{{ __('company.platform_name') }}</label>
<input type="text" class="form-control" id="platform_name" name="platform_name" value="{{ target_company ? target_company.platform_name : '' }}" placeholder="{{ __('company.platform_name_placeholder') }}">
<div class="form-text">{{ __('company.platform_name_help') }}</div>
</div>
</div>
</div>
{% endif %}
<div class="card mb-4 border-primary">
<div class="card-header bg-primary text-white">
<i class="bi bi-robot me-1"></i> {{ __('company.ai_agent_config_title') }}
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label for="ai_provider" class="form-label">{{ __('company.ai_provider') }}</label>
<select class="form-select" id="ai_provider" name="ai_provider">
<option value="openrouter" {{ target_company and target_company.ai_provider == 'openrouter' ? 'selected' : '' }}>OpenRouter ({{ __('company.recommended') }})</option>
<option value="openai" {{ target_company and target_company.ai_provider == 'openai' ? 'selected' : '' }}>OpenAI (Direct)</option>
<option value="gemini" {{ target_company and target_company.ai_provider == 'gemini' ? 'selected' : '' }}>Google Gemini (Direct)</option>
<option value="zai" {{ target_company and target_company.ai_provider == 'zai' ? 'selected' : '' }}>Z.ai (Direct)</option>
<option value="ollama" {{ target_company and target_company.ai_provider == 'ollama' ? 'selected' : '' }}>Ollama (Local)</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="ai_model" class="form-label">{{ __('company.ai_model') }}</label>
<input type="text" class="form-control" id="ai_model" name="ai_model" value="{{ target_company ? target_company.ai_model : 'google/gemini-2.0-flash-001' }}" placeholder="ex: stepfun/step-3.5-flash:free">
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="ai_endpoint" class="form-label">{{ __('company.ai_endpoint') }} ({{ __('company.optional') }})</label>
<input type="text" class="form-control" id="ai_endpoint" name="ai_endpoint" value="{{ target_company ? target_company.ai_endpoint : '' }}" placeholder="http://localhost:11434/v1">
</div>
</div>
</div>
<div class="mb-0">
<label for="openrouter_api_key" class="form-label">{{ __('company.api_key_secret') }}</label>
<input type="password" class="form-control" id="openrouter_api_key" name="openrouter_api_key" value="{{ target_company ? target_company.openrouter_api_key : '' }}" placeholder="sk-...">
<div class="form-text">{{ __('company.api_key_help') }}</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="address" class="form-label">{{ __('company.address') }}</label>
<input type="text" class="form-control" id="address" name="address" value="{{ target_company ? target_company.bus_address : '' }}">
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="city" class="form-label">{{ __('company.city') }}</label>
<input type="text" class="form-control" id="city" name="city" value="{{ target_company ? target_company.bus_city : '' }}">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="mb-3">
<label for="state" class="form-label">{{ __('company.state') }}</label>
<input type="text" class="form-control" id="state" name="state" value="{{ target_company ? target_company.bus_state : '' }}">
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="country" class="form-label">{{ __('company.country') }}</label>
<input type="text" class="form-control" id="country" name="country" value="{{ target_company ? target_company.bus_country : '' }}">
</div>
</div>
<div class="col-md-4">
<div class="mb-3">
<label for="postal_code" class="form-label">{{ __('company.postal_code') }}</label>
<input type="text" class="form-control" id="postal_code" name="postal_code" value="{{ target_company ? target_company.bus_postal_code : '' }}">
</div>
</div>
</div>
{% if user.isSuperAdmin() %}
<div class="card mb-3">
<div class="card-header">
{{ __('company.module_visibility_title') }}
</div>
<div class="card-body">
{% if modules %}
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>{{ __('company.module_header') }}</th>
<th class="text-center">{{ __('company.enabled_header') }}</th>
<th class="text-center">{{ __('company.public_navbar_header') }}</th>
<th class="text-center">{{ __('company.dashboard_navbar_header') }}</th>
</tr>
</thead>
<tbody>
{% for module in modules %}
{% set isEnabled = false %}
{% set showPublic = true %}
{% set showDashboard = true %}
{% if target_company %}
{% for cm in target_company.modules %}
{% if cm.modules_id == module.modules_id %}
{% set isEnabled = cm.pivot.bus_modules_is_enabled %}
{% set showPublic = cm.pivot.bus_modules_show_public_nav %}
{% set showDashboard = cm.pivot.bus_modules_show_dashboard_nav %}
{% endif %}
{% endfor %}
{% endif %}
<tr>
<td>
<input type="hidden" name="modules[{{ module.modules_id }}][present]" value="1">
<strong>{{ module.modules_display_name }}</strong>
<small class="d-block text-muted">{{ module.modules_description }}</small>
</td>
<td class="text-center">
<div class="form-check d-inline-block">
<input class="form-check-input" type="checkbox" name="modules[{{ module.modules_id }}][enabled]" id="module_enabled_{{ module.modules_id }}" {{ isEnabled ? 'checked' : '' }}>
</div>
</td>
<td class="text-center">
<div class="form-check d-inline-block">
<input class="form-check-input" type="checkbox" name="modules[{{ module.modules_id }}][public]" id="module_public_{{ module.modules_id }}" {{ showPublic ? 'checked' : '' }}>
</div>
</td>
<td class="text-center">
<div class="form-check d-inline-block">
<input class="form-check-input" type="checkbox" name="modules[{{ module.modules_id }}][dashboard]" id="module_dashboard_{{ module.modules_id }}" {{ showDashboard ? 'checked' : '' }}>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="text-muted mb-0">{{ __('company.no_active_modules') }}</p>
{% endif %}
</div>
</div>
{% endif %}
<div class="mb-3">
<label for="logo" class="form-label">{{ __('company.logo') }}</label>
<input type="file" class="form-control" id="logo" name="logo" accept="image/*">
<div id="logoPreview" class="mt-2"></div>
{% if target_company and target_company.bus_logo %}
<div class="mt-2">
<small class="form-text text-muted">{{ __('company.current_logo') }}</small>
<img src="{{ target_company.logo_url }}" alt="{{ __('company.alt_logo') }}" class="img-thumbnail" style="max-height: 100px;">
</div>
{% endif %}
</div>
<div class="mb-3">
<label for="business_card" class="form-label">{{ __('company.business_card') }}</label>
<input type="file" class="form-control" id="business_card" name="business_card" accept="image/*">
<div id="businessCardPreview" class="mt-2"></div>
{% if target_company and target_company.bus_business_card %}
<div class="mt-2">
<small class="form-text text-muted">{{ __('company.current_business_card') }}</small>
<img src="{{ target_company.business_card_url }}" alt="{{ __('company.alt_business_card') }}" class="img-thumbnail" style="max-height: 100px;">
</div>
{% endif %}
</div>
<div class="mt-4 border-top pt-3">
<button type="submit" class="btn btn-primary"><i class="bi bi-save me-1"></i> {{ target_company ? __('company.update_button') : __('company.create_button') }}</button>
<a href="{{ url('admin/companies') }}" class="btn btn-secondary"><i class="bi bi-x-lg me-1"></i> {{ __('company.cancel') }}</a>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
// Logo Preview
document.getElementById('logo').addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('logoPreview').innerHTML = `<img src="${e.target.result}" class="img-thumbnail" style="max-height: 100px;">`;
}
reader.readAsDataURL(file);
}
});
// Business Card Preview
document.getElementById('business_card').addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('businessCardPreview').innerHTML = `<img src="${e.target.result}" class="img-thumbnail" style="max-height: 100px;">`;
}
reader.readAsDataURL(file);
}
});
</script>
{% endblock %}