- Add new route /vendor/{code}/orders/{order_id} for order details
- Create order-detail.html template with:
- Order summary with status and totals
- Order items with per-item shipment status and ship buttons
- Customer and shipping address display
- Invoice section (create invoice or view existing)
- Quick actions (confirm, ship all, mark delivered, cancel)
- Status update modal with tracking info fields
- Ship all modal for bulk shipment with tracking
- Create order-detail.js with full functionality:
- Load order details, shipment status, and linked invoice
- Individual item shipping with partial shipment support
- Ship all remaining items with tracking info
- Create invoice from order
- Download invoice PDF
- Status management with automatic shipment handling
- Update orders list to navigate to detail page instead of modal
- Add partially_shipped status (orange) to orders list
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
340 lines
16 KiB
HTML
340 lines
16 KiB
HTML
{# app/templates/vendor/orders.html #}
|
|
{% extends "vendor/base.html" %}
|
|
{% from 'shared/macros/pagination.html' import pagination %}
|
|
{% from 'shared/macros/headers.html' import page_header_flex, refresh_button %}
|
|
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
|
{% from 'shared/macros/modals.html' import modal_simple %}
|
|
|
|
{% block title %}Orders{% endblock %}
|
|
|
|
{% block alpine_data %}vendorOrders(){% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Page Header -->
|
|
{% call page_header_flex(title='Orders', subtitle='View and manage your orders') %}
|
|
<div class="flex items-center gap-4">
|
|
{{ refresh_button(loading_var='loading', onclick='loadOrders()', variant='secondary') }}
|
|
</div>
|
|
{% endcall %}
|
|
|
|
{{ loading_state('Loading orders...') }}
|
|
|
|
{{ error_state('Error loading orders') }}
|
|
|
|
<!-- Stats Cards -->
|
|
<div x-show="!loading" class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
|
|
<!-- Total Orders -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-purple-500 bg-purple-100 rounded-full dark:text-purple-100 dark:bg-purple-500">
|
|
<span x-html="$icon('document-text', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Total Orders</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.total">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pending -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-yellow-500 bg-yellow-100 rounded-full dark:text-yellow-100 dark:bg-yellow-500">
|
|
<span x-html="$icon('clock', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Pending</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.pending">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Processing -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-blue-500 bg-blue-100 rounded-full dark:text-blue-100 dark:bg-blue-500">
|
|
<span x-html="$icon('arrow-path', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Processing</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.processing">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Completed -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-green-500 bg-green-100 rounded-full dark:text-green-100 dark:bg-green-500">
|
|
<span x-html="$icon('check-circle', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Completed</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.completed">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filters -->
|
|
<div x-show="!loading" class="mb-6 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="flex flex-wrap items-center gap-4">
|
|
<!-- Search -->
|
|
<div class="flex-1 min-w-[200px]">
|
|
<div class="relative">
|
|
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
|
|
<span x-html="$icon('search', 'w-5 h-5 text-gray-400')"></span>
|
|
</span>
|
|
<input
|
|
type="text"
|
|
x-model="filters.search"
|
|
@input="debouncedSearch()"
|
|
placeholder="Search by order #, customer..."
|
|
class="w-full pl-10 pr-4 py-2 text-sm text-gray-700 placeholder-gray-400 bg-gray-50 border border-gray-200 rounded-lg dark:placeholder-gray-500 dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Status Filter -->
|
|
<select
|
|
x-model="filters.status"
|
|
@change="applyFilter()"
|
|
class="px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
>
|
|
<option value="">All Statuses</option>
|
|
<template x-for="status in statuses" :key="status.value">
|
|
<option :value="status.value" x-text="status.label"></option>
|
|
</template>
|
|
</select>
|
|
|
|
<!-- Date From -->
|
|
<input
|
|
type="date"
|
|
x-model="filters.date_from"
|
|
@change="applyFilter()"
|
|
class="px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
/>
|
|
|
|
<!-- Date To -->
|
|
<input
|
|
type="date"
|
|
x-model="filters.date_to"
|
|
@change="applyFilter()"
|
|
class="px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
/>
|
|
|
|
<!-- Clear Filters -->
|
|
<button
|
|
x-show="filters.search || filters.status || filters.date_from || filters.date_to"
|
|
@click="clearFilters()"
|
|
class="px-4 py-2 text-sm text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"
|
|
>
|
|
Clear filters
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bulk Actions Bar -->
|
|
<div x-show="!loading && selectedOrders.length > 0"
|
|
x-transition:enter="transition ease-out duration-200"
|
|
x-transition:enter-start="opacity-0 -translate-y-2"
|
|
x-transition:enter-end="opacity-100 translate-y-0"
|
|
class="mb-4 p-3 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg flex items-center justify-between">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-sm font-medium text-purple-700 dark:text-purple-300">
|
|
<span x-text="selectedOrders.length"></span> order(s) selected
|
|
</span>
|
|
<button @click="clearSelection()" class="text-sm text-purple-600 hover:text-purple-800 dark:text-purple-400">
|
|
Clear
|
|
</button>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<button
|
|
@click="openBulkStatusModal()"
|
|
:disabled="saving"
|
|
class="px-3 py-1.5 text-sm font-medium text-blue-700 bg-blue-100 rounded-lg hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:hover:bg-blue-800 disabled:opacity-50"
|
|
>
|
|
<span x-html="$icon('pencil-square', 'w-4 h-4 inline mr-1')"></span>
|
|
Update Status
|
|
</button>
|
|
<button
|
|
@click="exportSelectedOrders()"
|
|
class="px-3 py-1.5 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"
|
|
>
|
|
<span x-html="$icon('arrow-down-tray', 'w-4 h-4 inline mr-1')"></span>
|
|
Export CSV
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Orders Table -->
|
|
<div x-show="!loading && !error" class="w-full mb-8 overflow-hidden rounded-lg shadow-xs">
|
|
<div class="w-full overflow-x-auto">
|
|
<table class="w-full whitespace-no-wrap">
|
|
<thead>
|
|
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
|
<th class="px-4 py-3 w-10">
|
|
<input
|
|
type="checkbox"
|
|
:checked="allSelected"
|
|
:indeterminate="someSelected"
|
|
@click="toggleSelectAll()"
|
|
class="w-4 h-4 text-purple-600 rounded focus:ring-purple-500 dark:bg-gray-700 dark:border-gray-600"
|
|
/>
|
|
</th>
|
|
<th class="px-4 py-3">Order #</th>
|
|
<th class="px-4 py-3">Customer</th>
|
|
<th class="px-4 py-3">Date</th>
|
|
<th class="px-4 py-3">Total</th>
|
|
<th class="px-4 py-3">Status</th>
|
|
<th class="px-4 py-3">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
|
<template x-for="order in orders" :key="order.id">
|
|
<tr class="text-gray-700 dark:text-gray-400" :class="{'bg-purple-50 dark:bg-purple-900/10': isSelected(order.id)}">
|
|
<!-- Checkbox -->
|
|
<td class="px-4 py-3">
|
|
<input
|
|
type="checkbox"
|
|
:checked="isSelected(order.id)"
|
|
@click="toggleSelect(order.id)"
|
|
class="w-4 h-4 text-purple-600 rounded focus:ring-purple-500 dark:bg-gray-700 dark:border-gray-600"
|
|
/>
|
|
</td>
|
|
<!-- Order Number -->
|
|
<td class="px-4 py-3">
|
|
<span class="font-mono font-semibold" x-text="order.order_number || `#${order.id}`"></span>
|
|
</td>
|
|
<!-- Customer -->
|
|
<td class="px-4 py-3">
|
|
<div class="text-sm">
|
|
<p class="font-medium" x-text="order.customer_name || 'Guest'"></p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400" x-text="order.customer_email || ''"></p>
|
|
</div>
|
|
</td>
|
|
<!-- Date -->
|
|
<td class="px-4 py-3 text-sm" x-text="formatDate(order.created_at)"></td>
|
|
<!-- Total -->
|
|
<td class="px-4 py-3 text-sm font-semibold" x-text="formatPrice(order.total)"></td>
|
|
<!-- Status -->
|
|
<td class="px-4 py-3 text-xs">
|
|
<span
|
|
:class="{
|
|
'px-2 py-1 font-semibold leading-tight rounded-full': true,
|
|
'text-yellow-700 bg-yellow-100 dark:bg-yellow-700 dark:text-yellow-100': getStatusColor(order.status) === 'yellow',
|
|
'text-blue-700 bg-blue-100 dark:bg-blue-700 dark:text-blue-100': getStatusColor(order.status) === 'blue',
|
|
'text-orange-700 bg-orange-100 dark:bg-orange-700 dark:text-orange-100': getStatusColor(order.status) === 'orange',
|
|
'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100': getStatusColor(order.status) === 'green',
|
|
'text-red-700 bg-red-100 dark:bg-red-700 dark:text-red-100': getStatusColor(order.status) === 'red',
|
|
'text-indigo-700 bg-indigo-100 dark:bg-indigo-700 dark:text-indigo-100': getStatusColor(order.status) === 'indigo',
|
|
'text-gray-700 bg-gray-100 dark:bg-gray-700 dark:text-gray-100': getStatusColor(order.status) === 'gray'
|
|
}"
|
|
x-text="getStatusLabel(order.status)"
|
|
></span>
|
|
</td>
|
|
<!-- Actions -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center space-x-2 text-sm">
|
|
<button
|
|
@click="viewOrder(order)"
|
|
class="p-1 text-gray-500 hover:text-purple-600 dark:text-gray-400 dark:hover:text-purple-400"
|
|
title="View Details"
|
|
>
|
|
<span x-html="$icon('eye', 'w-5 h-5')"></span>
|
|
</button>
|
|
<button
|
|
@click="openStatusModal(order)"
|
|
class="p-1 text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400"
|
|
title="Update Status"
|
|
>
|
|
<span x-html="$icon('pencil-square', 'w-5 h-5')"></span>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
<!-- Empty State -->
|
|
<tr x-show="orders.length === 0">
|
|
<td colspan="7" class="px-4 py-8 text-center text-gray-500 dark:text-gray-400">
|
|
<div class="flex flex-col items-center">
|
|
<span x-html="$icon('document-text', 'w-12 h-12 text-gray-300 dark:text-gray-600 mb-4')"></span>
|
|
<p class="text-lg font-medium">No orders found</p>
|
|
<p class="text-sm">Orders will appear here when customers make purchases</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
<div x-show="!loading && pagination.total > 0" class="mb-8">
|
|
{{ pagination(
|
|
current_page='pagination.page',
|
|
total_pages='totalPages',
|
|
total_items='pagination.total',
|
|
start_index='startIndex',
|
|
end_index='endIndex',
|
|
page_numbers='pageNumbers',
|
|
previous_fn='previousPage()',
|
|
next_fn='nextPage()',
|
|
goto_fn='goToPage'
|
|
) }}
|
|
</div>
|
|
|
|
<!-- Status Update Modal -->
|
|
{{ modal_simple(
|
|
show_var='showStatusModal',
|
|
title='Update Order Status',
|
|
icon='pencil-square',
|
|
icon_color='blue',
|
|
confirm_text='Update',
|
|
confirm_class='bg-purple-600 hover:bg-purple-700 focus:shadow-outline-purple',
|
|
confirm_fn='updateStatus()',
|
|
loading_var='saving'
|
|
) }}
|
|
<template x-if="showStatusModal && selectedOrder">
|
|
<div class="mb-4">
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
|
Update status for order <span class="font-semibold" x-text="selectedOrder.order_number || `#${selectedOrder.id}`"></span>
|
|
</p>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">New Status</label>
|
|
<select
|
|
x-model="newStatus"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
>
|
|
<template x-for="status in statuses" :key="status.value">
|
|
<option :value="status.value" x-text="status.label"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
</template>
|
|
|
|
<!-- Bulk Status Update Modal -->
|
|
{{ modal_simple(
|
|
show_var='showBulkStatusModal',
|
|
title='Bulk Update Status',
|
|
icon='pencil-square',
|
|
icon_color='blue',
|
|
confirm_text='Update All',
|
|
confirm_class='bg-purple-600 hover:bg-purple-700 focus:shadow-outline-purple',
|
|
confirm_fn='bulkUpdateStatus()',
|
|
loading_var='saving'
|
|
) }}
|
|
<template x-if="showBulkStatusModal">
|
|
<div class="mb-4">
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
|
Update status for <span class="font-semibold" x-text="selectedOrders.length"></span> selected order(s)
|
|
</p>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">New Status</label>
|
|
<select
|
|
x-model="bulkStatus"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
>
|
|
<option value="">Select a status...</option>
|
|
<template x-for="status in statuses" :key="status.value">
|
|
<option :value="status.value" x-text="status.label"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
</template>
|
|
{% endblock %}
|
|
|
|
{% block extra_scripts %}
|
|
<script src="{{ url_for('static', path='vendor/js/orders.js') }}"></script>
|
|
{% endblock %}
|