{t("All Organizations")}

{t_admin("Manage organizations")}

Global Billing Defaults

Default pricing for all organizations (can be overridden per-org)

Free Devices
{@default_free_devices}
Price Per Device
${@default_price}/mo
<.table id="organizations" rows={@organizations}> <:col :let={org} label={t("Name")}>{org.name} <:col :let={org} label={t("Slug")}>{org.slug} <:col :let={org} label={t("Plan")}> {org.subscription_plan} <:col :let={org} label={t("Devices")}> {org.device_count} <:col :let={org} label={t("Overrides")}> <%= if org.custom_free_device_limit || org.custom_price_per_device do %>
<%= if org.custom_free_device_limit do %> {org.custom_free_device_limit} {t("free")} <% end %> <%= if org.custom_price_per_device do %> ${org.custom_price_per_device}/{t("device")} <% end %>
<% else %> {t("Default")} <% end %> <:col :let={org} label={t("Members")}>{length(org.memberships)} <:col :let={org} label={t("Created")}> {ToweropsWeb.TimeHelpers.format_date(org.inserted_at, @timezone)} <:col :let={org} label="">
<.button id={"edit-overrides-#{org.id}"} phx-click="edit_overrides" phx-value-id={org.id} variant="secondary" > {t_admin("Edit")} <.button phx-click="delete_org" phx-value-id={org.id} data-confirm={ t( "Are you sure? This will delete all sites, device, and data for this organization." ) } variant="danger" > {t("Delete")}
<%!-- Billing Override Edit Panel --%> <%= if @editing_org do %>

{t_admin("Billing Overrides")} — {@editing_org.name}

<.form for={@override_form} id="billing-override-form" phx-change="validate_overrides" phx-submit="save_overrides" >
<.input field={@override_form[:custom_free_device_limit]} type="number" label={t_admin("Custom Free Device Limit")} placeholder="10 (default)" min="1" max="9999" /> <.input field={@override_form[:custom_price_per_device]} type="number" label={t_admin("Custom Price Per Device")} placeholder="1.00 (default)" step="0.01" min="0" max="999.99" />
<.button type="submit" phx-disable-with={t("Saving...")}> {t("Save")}
<% end %> <%!-- Edit Global Defaults Modal --%> <%= if @editing_global do %>

Edit Global Billing Defaults

<.form id="global-pricing-form" for={@global_form} phx-change="validate_global_pricing" phx-submit="save_global_pricing" data-test="global-defaults-form" class="mt-6 space-y-4" >
<%= if error = @global_form.errors[:default_free_devices] do %>

{elem(error, 0)}

<% end %>
<%= if error = @global_form.errors[:default_price_per_device] do %>

{elem(error, 0)}

<% end %>
<%!-- Confirmation Dialog --%> <%= if @show_confirm do %>

Confirm Price Change

This will update {@active_sub_count} active subscriptions to the new price. Changes take effect at the next billing cycle.

<% end %>
<% end %>