Aggiunge abbonamenti omaggio admin per sponsor e promozioni.
Gli admin possono concedere o revocare Premium Light/Full senza Stripe; il piano omaggio ha priorità sui webhook e la società vede un messaggio dedicato. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,13 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if @filter_club %>
|
||||
<%= render "admin/clubs/comped_form",
|
||||
club: @filter_club,
|
||||
subscription: @filter_club.subscription,
|
||||
return_to: admin_billing_path(club_id: @filter_club.id) %>
|
||||
<% end %>
|
||||
|
||||
<% if @pending_payments.any? %>
|
||||
<div class="billing-pending-list">
|
||||
<% @pending_payments.each do |payment| %>
|
||||
|
||||
56
backend/app/views/admin/clubs/_comped_form.html.erb
Normal file
56
backend/app/views/admin/clubs/_comped_form.html.erb
Normal file
@@ -0,0 +1,56 @@
|
||||
<%# locals: (club:, subscription:, return_to: nil) %>
|
||||
<section class="admin-comped-card" style="margin-bottom:24px;padding:16px;border:1px solid #3d3520;border-radius:8px;background:#2a2618">
|
||||
<h2 style="margin:0 0 8px;font-size:1.1rem">Abbonamento omaggio</h2>
|
||||
<p style="color:#bbb;font-size:0.9rem;margin:0 0 14px">
|
||||
Sponsor o promozione: assegna Premium Light/Full senza pagamento Stripe. Revocabile in qualsiasi momento.
|
||||
</p>
|
||||
|
||||
<% sub = subscription %>
|
||||
<% if sub&.admin_comped? %>
|
||||
<p style="margin:0 0 12px">
|
||||
<strong>Attivo:</strong> <%= sub.plan.name %>
|
||||
<% if sub.admin_comped_reason.present? %>
|
||||
· <%= sub.admin_comped_reason %>
|
||||
<% end %>
|
||||
<% if sub.admin_comped_at.present? %>
|
||||
<br><span style="color:#888;font-size:0.85rem">Dal <%= l(sub.admin_comped_at, format: :long) %>
|
||||
<% if sub.admin_comped_by.present? %> · admin <%= sub.admin_comped_by.username %><% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if sub.stripe_subscription_id.present? %>
|
||||
<br><span style="color:#888;font-size:0.85rem">Nota: esiste anche un abbonamento Stripe collegato; l’omaggio ha priorità sul piano.</span>
|
||||
<% end %>
|
||||
</p>
|
||||
<%= button_to "Revoca omaggio (torna Free o ripristina Stripe)",
|
||||
revoke_comped_admin_club_path(club, return_to: return_to),
|
||||
method: :delete,
|
||||
class: "admin-btn admin-btn--secondary",
|
||||
form: { data: { turbo_confirm: "Revocare l’abbonamento omaggio per #{club.name}?" } } %>
|
||||
<% else %>
|
||||
<p style="margin:0 0 12px;color:#888">
|
||||
Piano attuale: <strong><%= sub&.plan&.name || "Free" %></strong>
|
||||
<% if sub&.stripe_subscription_id.present? %>
|
||||
· pagamento Stripe attivo
|
||||
<% end %>
|
||||
</p>
|
||||
<%= form_with url: grant_comped_admin_club_path(club), method: :post, local: true, class: "admin-comped-form" do %>
|
||||
<%= hidden_field_tag :return_to, return_to if return_to.present? %>
|
||||
<div style="display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end">
|
||||
<label style="display:flex;flex-direction:column;gap:4px;font-size:0.85rem">
|
||||
Piano
|
||||
<%= select_tag :plan_slug,
|
||||
options_for_select(
|
||||
[["Premium Light", "premium_light"], ["Premium Full", "premium_full"]]
|
||||
),
|
||||
required: true,
|
||||
class: "admin-input" %>
|
||||
</label>
|
||||
<label style="display:flex;flex-direction:column;gap:4px;font-size:0.85rem;flex:1;min-width:200px">
|
||||
Motivo (es. sponsor 2026)
|
||||
<%= text_field_tag :reason, nil, placeholder: "Sponsor, promozione…", class: "admin-input", style: "width:100%" %>
|
||||
</label>
|
||||
<%= submit_tag "Concedi omaggio", class: "admin-btn admin-btn--primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</section>
|
||||
38
backend/app/views/admin/clubs/index.html.erb
Normal file
38
backend/app/views/admin/clubs/index.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
<h2>Società</h2>
|
||||
<p style="color:#888;margin-bottom:16px">
|
||||
Gestisci abbonamenti omaggio (sponsor / promozioni). Per pagamenti Stripe usa <%= link_to "Fatturazione", admin_billing_path %>.
|
||||
</p>
|
||||
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Società</th>
|
||||
<th>Piano</th>
|
||||
<th>Omaggio</th>
|
||||
<th>Stripe</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @clubs.each do |club| %>
|
||||
<% sub = club.subscription %>
|
||||
<tr>
|
||||
<td><strong><%= club.name %></strong></td>
|
||||
<td><%= sub&.plan&.name || "Free" %></td>
|
||||
<td>
|
||||
<% if sub&.admin_comped? %>
|
||||
<span style="color:#ffb74d">Sì</span>
|
||||
<% if sub.admin_comped_reason.present? %> · <%= sub.admin_comped_reason %><% end %>
|
||||
<% else %>
|
||||
—
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= sub&.stripe_subscription_id.present? ? "Sì" : "—" %></td>
|
||||
<td>
|
||||
<%= link_to "Gestisci", admin_club_path(club) %>
|
||||
· <%= link_to "Fatture", admin_billing_path(club_id: club.id) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
16
backend/app/views/admin/clubs/show.html.erb
Normal file
16
backend/app/views/admin/clubs/show.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<p style="margin-bottom:16px"><%= link_to "← Tutte le società", admin_clubs_path %></p>
|
||||
|
||||
<h2><%= @club.name %></h2>
|
||||
<p style="color:#888">
|
||||
Sport: <%= @club.sport %>
|
||||
· <%= link_to "Pagamenti e fatture", admin_billing_path(club_id: @club.id) %>
|
||||
</p>
|
||||
|
||||
<%= render "admin/clubs/comped_form", club: @club, subscription: @subscription, return_to: admin_club_path(@club) %>
|
||||
|
||||
<h3 style="font-size:1rem;margin-top:24px">Squadre</h3>
|
||||
<ul>
|
||||
<% @club.teams.order(:name).each do |team| %>
|
||||
<li><%= link_to team.name, admin_team_path(team) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
@@ -17,6 +17,7 @@
|
||||
<% if admin_logged_in? %>
|
||||
<%= link_to "Dashboard", admin_root_path, class: ("active" if controller_name == "dashboard") %>
|
||||
<%= link_to "Teams", admin_teams_path, class: ("active" if controller_name == "teams") %>
|
||||
<%= link_to "Società", admin_clubs_path, class: ("active" if controller_name == "clubs") %>
|
||||
<%= link_to "Fatturazione", admin_billing_path, class: ("active" if controller_name.in?(%w[billing billing_invoices])) %>
|
||||
<%= link_to "YouTube", admin_youtube_platform_path, class: ("active" if controller_name == "youtube") %>
|
||||
<%= link_to "Sessions", admin_sessions_path, class: ("active" if controller_name == "sessions") %>
|
||||
|
||||
@@ -5,12 +5,26 @@
|
||||
<h1>Abbonamento</h1>
|
||||
<%= render "shared/club_subscription_status", club: @club, entitlements: @entitlements, subscription: @subscription, on_billing_page: true %>
|
||||
|
||||
<%= render "shared/stripe_secure_payment" %>
|
||||
<% if MatchLiveTv.stripe_enabled? %>
|
||||
<%= render "shared/plan_change_info", subscription: @subscription %>
|
||||
<% if @subscription&.admin_comped? %>
|
||||
<div class="card" style="margin-top:16px;border-color:#3d3520;background:#1a1810">
|
||||
<p style="margin:0;color:#ddd">
|
||||
<strong>Abbonamento omaggio Match Live TV</strong>
|
||||
— piano <strong><%= @subscription.plan.name %></strong>
|
||||
<% if @subscription.admin_comped_reason.present? %>
|
||||
(<%= @subscription.admin_comped_reason %>)
|
||||
<% end %>.
|
||||
Non è richiesto alcun pagamento. Per modifiche o passaggio a un piano a pagamento, contatta
|
||||
<%= mail_to "info@matchlive.it", "info@matchlive.it" %>.
|
||||
</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render "shared/stripe_secure_payment" %>
|
||||
<% if MatchLiveTv.stripe_enabled? %>
|
||||
<%= render "shared/plan_change_info", subscription: @subscription %>
|
||||
<% end %>
|
||||
<%= render "shared/plan_cards", show_stripe_portal: false %>
|
||||
<%= render "shared/subscription_cancel", club: @club, subscription: @subscription %>
|
||||
<% end %>
|
||||
<%= render "shared/plan_cards", show_stripe_portal: false %>
|
||||
<%= render "shared/subscription_cancel", club: @club, subscription: @subscription %>
|
||||
|
||||
<%= render "shared/billing_documents", club: @club, payments: @payments %>
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<p style="color:#aaa;margin-bottom:8px">
|
||||
Società: <strong><%= club.name %></strong>
|
||||
· Piano attuale: <strong><%= current_plan.name %></strong>
|
||||
<% if subscription&.admin_comped? %>
|
||||
<span style="color:#ffb74d">(omaggio Match Live TV)</span>
|
||||
<% end %>
|
||||
(valido per tutte le squadre)
|
||||
<% unless local_assigns[:on_billing_page] %>
|
||||
· <%= link_to "Gestisci abbonamento", public_club_billing_path(club) %>
|
||||
|
||||
Reference in New Issue
Block a user