started implementing stripe

This commit is contained in:
2025-06-26 15:15:16 +02:00
parent 3a0659b63b
commit 9b85f3bb8d
24 changed files with 2025 additions and 103 deletions

View File

@@ -0,0 +1,149 @@
<div class="row">
<div class="col-md-6">
<h6 class="mb-3">Customer Information</h6>
<table class="table table-sm">
<tr>
<td><strong>Name:</strong></td>
<td>{{ customer.name or 'N/A' }}</td>
</tr>
<tr>
<td><strong>Email:</strong></td>
<td>{{ customer.email }}</td>
</tr>
<tr>
<td><strong>Phone:</strong></td>
<td>{{ customer.phone or 'N/A' }}</td>
</tr>
<tr>
<td><strong>Created:</strong></td>
<td>{{ customer.created_at.strftime('%Y-%m-%d %H:%M') if customer.created_at else 'N/A' }}</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6 class="mb-3">Subscription Information</h6>
<table class="table table-sm">
<tr>
<td><strong>Plan:</strong></td>
<td>
{% if plan %}
<span class="badge bg-primary">{{ plan.name }}</span>
{% else %}
<span class="text-muted">Plan {{ customer.subscription_plan_id or 'N/A' }}</span>
{% endif %}
</td>
</tr>
<tr>
<td><strong>Status:</strong></td>
<td>
{% if customer.subscription_status %}
{% if customer.subscription_status == 'active' %}
<span class="badge bg-success">Active</span>
{% elif customer.subscription_status == 'canceled' %}
<span class="badge bg-danger">Canceled</span>
{% elif customer.subscription_status == 'past_due' %}
<span class="badge bg-warning">Past Due</span>
{% else %}
<span class="badge bg-secondary">{{ customer.subscription_status }}</span>
{% endif %}
{% else %}
<span class="text-muted">No subscription</span>
{% endif %}
</td>
</tr>
<tr>
<td><strong>Billing Cycle:</strong></td>
<td>
{% if customer.subscription_billing_cycle %}
<span class="badge bg-info">{{ customer.subscription_billing_cycle.title() }}</span>
{% else %}
<span class="text-muted">N/A</span>
{% endif %}
</td>
</tr>
<tr>
<td><strong>Current Period:</strong></td>
<td>
{% if customer.subscription_current_period_start and customer.subscription_current_period_end %}
{{ customer.subscription_current_period_start.strftime('%Y-%m-%d') }} to {{ customer.subscription_current_period_end.strftime('%Y-%m-%d') }}
{% else %}
<span class="text-muted">N/A</span>
{% endif %}
</td>
</tr>
</table>
</div>
</div>
{% if customer.billing_address_line1 or customer.shipping_address_line1 %}
<div class="row mt-4">
{% if customer.billing_address_line1 %}
<div class="col-md-6">
<h6 class="mb-3">Billing Address</h6>
<address class="mb-0">
{{ customer.billing_address_line1 }}<br>
{% if customer.billing_address_line2 %}{{ customer.billing_address_line2 }}<br>{% endif %}
{% if customer.billing_city %}{{ customer.billing_city }}{% endif %}
{% if customer.billing_state %}, {{ customer.billing_state }}{% endif %}
{% if customer.billing_postal_code %} {{ customer.billing_postal_code }}{% endif %}<br>
{% if customer.billing_country %}{{ customer.billing_country }}{% endif %}
</address>
</div>
{% endif %}
{% if customer.shipping_address_line1 %}
<div class="col-md-6">
<h6 class="mb-3">Shipping Address</h6>
<address class="mb-0">
{{ customer.shipping_address_line1 }}<br>
{% if customer.shipping_address_line2 %}{{ customer.shipping_address_line2 }}<br>{% endif %}
{% if customer.shipping_city %}{{ customer.shipping_city }}{% endif %}
{% if customer.shipping_state %}, {{ customer.shipping_state }}{% endif %}
{% if customer.shipping_postal_code %} {{ customer.shipping_postal_code }}{% endif %}<br>
{% if customer.shipping_country %}{{ customer.shipping_country }}{% endif %}
</address>
</div>
{% endif %}
</div>
{% endif %}
{% if customer.tax_id_type and customer.tax_id_value %}
<div class="row mt-4">
<div class="col-12">
<h6 class="mb-3">Tax Information</h6>
<table class="table table-sm">
<tr>
<td><strong>Tax ID Type:</strong></td>
<td>{{ customer.tax_id_type }}</td>
</tr>
<tr>
<td><strong>Tax ID Value:</strong></td>
<td>{{ customer.tax_id_value }}</td>
</tr>
</table>
</div>
</div>
{% endif %}
{% if customer.stripe_customer_id or customer.stripe_subscription_id %}
<div class="row mt-4">
<div class="col-12">
<h6 class="mb-3">Stripe Information</h6>
<table class="table table-sm">
{% if customer.stripe_customer_id %}
<tr>
<td><strong>Stripe Customer ID:</strong></td>
<td><code>{{ customer.stripe_customer_id }}</code></td>
</tr>
{% endif %}
{% if customer.stripe_subscription_id %}
<tr>
<td><strong>Stripe Subscription ID:</strong></td>
<td><code>{{ customer.stripe_subscription_id }}</code></td>
</tr>
{% endif %}
</table>
</div>
</div>
{% endif %}

View File

@@ -0,0 +1,178 @@
{% extends "common/base.html" %}
{% from "components/header.html" import header %}
{% block title %}Customers - Admin{% endblock %}
{% block content %}
{{ header(
title="Customers",
description="Manage customer information and subscriptions",
icon="fa-users"
) }}
<div class="container-fluid">
{% if customers.items %}
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Plan</th>
<th>Status</th>
<th>Billing Cycle</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for customer in customers.items %}
<tr>
<td>
<div class="d-flex align-items-center">
<div class="avatar-sm me-3">
<div class="avatar-title bg-primary rounded-circle">
{{ customer.name[0] if customer.name else customer.email[0] }}
</div>
</div>
<div>
<h6 class="mb-0">{{ customer.name or 'N/A' }}</h6>
</div>
</div>
</td>
<td>{{ customer.email }}</td>
<td>{{ customer.phone or 'N/A' }}</td>
<td>
{% if customer.subscription_plan_id %}
{% set plan = customer.plan %}
{% if plan %}
<span class="badge bg-primary">{{ plan.name }}</span>
{% else %}
<span class="text-muted">Plan {{ customer.subscription_plan_id }}</span>
{% endif %}
{% else %}
<span class="text-muted">No plan</span>
{% endif %}
</td>
<td>
{% if customer.subscription_status %}
{% if customer.subscription_status == 'active' %}
<span class="badge bg-success">Active</span>
{% elif customer.subscription_status == 'canceled' %}
<span class="badge bg-danger">Canceled</span>
{% elif customer.subscription_status == 'past_due' %}
<span class="badge bg-warning">Past Due</span>
{% else %}
<span class="badge bg-secondary">{{ customer.subscription_status }}</span>
{% endif %}
{% else %}
<span class="text-muted">No subscription</span>
{% endif %}
</td>
<td>
{% if customer.subscription_billing_cycle %}
<span class="badge bg-info">{{ customer.subscription_billing_cycle.title() }}</span>
{% else %}
<span class="text-muted">N/A</span>
{% endif %}
</td>
<td>{{ customer.created_at.strftime('%Y-%m-%d') if customer.created_at else 'N/A' }}</td>
<td>
<button class="btn btn-sm btn-outline-primary"
onclick="viewCustomerDetails({{ customer.id }})">
<i class="fas fa-eye"></i>
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if customers.pages > 1 %}
<nav aria-label="Customer pagination">
<ul class="pagination justify-content-center">
{% if customers.has_prev %}
<li class="page-item">
<a class="page-link" href="{{ url_for('admin.customers', page=customers.prev_num) }}">Previous</a>
</li>
{% endif %}
{% for page_num in customers.iter_pages() %}
{% if page_num %}
{% if page_num != customers.page %}
<li class="page-item">
<a class="page-link" href="{{ url_for('admin.customers', page=page_num) }}">{{ page_num }}</a>
</li>
{% else %}
<li class="page-item active">
<span class="page-link">{{ page_num }}</span>
</li>
{% endif %}
{% else %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
{% endfor %}
{% if customers.has_next %}
<li class="page-item">
<a class="page-link" href="{{ url_for('admin.customers', page=customers.next_num) }}">Next</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</div>
</div>
{% else %}
<div class="card">
<div class="card-body text-center py-5">
<i class="fas fa-users fa-3x text-muted mb-3"></i>
<h5 class="text-muted">No customers found</h5>
<p class="text-muted">Customers will appear here once they complete a purchase.</p>
</div>
</div>
{% endif %}
</div>
<!-- Customer Details Modal -->
<div class="modal fade" id="customerDetailsModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Customer Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body" id="customerDetailsContent">
<!-- Content will be loaded here -->
</div>
</div>
</div>
</div>
<script>
function viewCustomerDetails(customerId) {
// Load customer details via AJAX
fetch(`/admin/customers/${customerId}`)
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('customerDetailsContent').innerHTML = data.html;
new bootstrap.Modal(document.getElementById('customerDetailsModal')).show();
} else {
alert('Failed to load customer details');
}
})
.catch(error => {
console.error('Error:', error);
alert('Failed to load customer details');
});
}
</script>
{% endblock %}

View File

@@ -1,4 +1,5 @@
{% extends "common/base.html" %}
{% from "components/header.html" import header %}
{% block title %}Support Articles - DocuPulse{% endblock %}
@@ -69,18 +70,24 @@
{% endblock %}
{% block content %}
{{ header(
title="Support Articles",
description="Create and manage help articles for users",
icon="fa-life-ring",
buttons=[
{
'text': 'Create New Article',
'url': '#',
'onclick': 'showCreateArticleModal()',
'icon': 'fa-plus',
'class': 'btn-primary'
}
]
) }}
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 mb-0" style="color: var(--primary-color);">
<i class="fas fa-life-ring me-2"></i>Support Articles
</h1>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createArticleModal">
<i class="fas fa-plus me-2"></i>Create New Article
</button>
</div>
<!-- Articles List -->
<div class="row" id="articlesList">
<!-- Articles will be loaded here via AJAX -->