Files
1sonhador 88a5659fe8 fix: Correct user permissions and UserModel query
- Fix storage permissions to use 'www' user instead of 'www-data'
- Fix UserModel getAllForAdmin query to avoid placeholders in LIMIT/OFFSET
- Import missing modules: Advertising, Dashboard, Analytics
- Update deploy script to copy files to public directory
2025-10-15 14:14:00 +01:00

142 lines
7.5 KiB
PHP

<?php
use App\Core\AssetPath;
use App\Core\OutputSanitize;
use App\Core\View;
?>
<div class="row" x-data="brandsManager" x-init="init()">
<div class="col-lg-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="card-title mb-0">Gestão de Marcas</h5>
<button type="button" class="btn btn-primary" @click="openCreateModal()">
<i class="ri-add-line"></i> Nova Marca
</button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-striped" id="brandsTable">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Slug</th>
<th>Status</th>
<th>Landing Pages</th>
<th>Criado em</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<template x-if="isLoading">
<tr>
<td colspan="7" class="text-center">
<div class="spinner-border spinner-border-sm" role="status">
<span class="visually-hidden">A carregar...</span>
</div>
A carregar marcas...
</td>
</tr>
</template>
<template x-if="!isLoading && brands.length === 0">
<tr>
<td colspan="7" class="text-center text-muted">
Nenhuma marca encontrada
</td>
</tr>
</template>
<template x-for="brand in brands" :key="brand.id">
<tr>
<td x-text="brand.id"></td>
<td x-text="brand.name || 'N/A'"></td>
<td><code x-text="brand.slug || 'N/A'"></code></td>
<td>
<span class="badge" :class="brand.status == 1 ? 'bg-success' : 'bg-danger'">
<span x-text="brand.status == 1 ? 'Ativo' : 'Inativo'"></span>
</span>
</td>
<td>
<a :href="`/advertising/landing-types?brand=${brand.id}`" class="btn btn-sm btn-outline-primary">
<i class="ri-landscape-line"></i> Ver Landing Pages
</a>
</td>
<td x-text="formatDate(brand.created_at)"></td>
<td>
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm btn-outline-primary" @click="openEditModal(brand)">
<i class="ri-edit-line"></i>
</button>
<button type="button" class="btn btn-sm btn-outline-danger" @click="openDeleteModal(brand)">
<i class="ri-delete-bin-line"></i>
</button>
</div>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Modal para Criar/Editar Marca -->
<div class="modal fade" :class="{ 'show d-block': showCreateModal }" tabindex="-1" aria-labelledby="brandModalLabel" aria-hidden="true" style="background-color: rgba(0,0,0,0.5);">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="brandModalLabel" x-text="currentBrand ? 'Editar Marca' : 'Nova Marca'"></h5>
<button type="button" class="btn-close" @click="showCreateModal = false" aria-label="Close"></button>
</div>
<div class="modal-body">
<form @submit.prevent="saveBrand()">
<input type="hidden" x-model="formData.id">
<div class="mb-3">
<label for="brandName" class="form-label">Nome da Marca <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="brandName" x-model="formData.name" required>
</div>
<div class="mb-3">
<label for="brandSlug" class="form-label">Slug <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="brandSlug" x-model="formData.slug" required>
<small class="text-muted">Identificador único para a marca (ex: hollywoodbets)</small>
</div>
<div class="mb-3">
<label for="brandStatus" class="form-label">Status</label>
<select class="form-select" id="brandStatus" x-model="formData.status">
<option value="1">Ativo</option>
<option value="0">Inativo</option>
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" @click="showCreateModal = false">Cancelar</button>
<button type="button" class="btn btn-primary" @click="saveBrand()">Guardar</button>
</div>
</div>
</div>
</div>
<!-- Modal para Confirmar Eliminação -->
<div class="modal fade" :class="{ 'show d-block': showDeleteModal }" tabindex="-1" aria-labelledby="deleteBrandModalLabel" aria-hidden="true" style="background-color: rgba(0,0,0,0.5);">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteBrandModalLabel">Confirmar Eliminação</h5>
<button type="button" class="btn-close" @click="showDeleteModal = false" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Tem a certeza que deseja eliminar a marca "<span x-text="brandToDelete?.name"></span>"?</p>
<p class="text-warning"><i class="ri-alert-line"></i> Esta ação não pode ser desfeita.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" @click="showDeleteModal = false">Cancelar</button>
<button type="button" class="btn btn-danger" @click="confirmDelete()">Eliminar</button>
</div>
</div>
</div>
</div>