fix
This commit is contained in:
@@ -67,9 +67,14 @@
|
||||
<div id="invoices-tab" class="tab-content hidden">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h2 class="text-3xl font-bold text-gray-800">Invoices</h2>
|
||||
<button onclick="openInvoiceModal()" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold shadow-md">
|
||||
+ New Invoice
|
||||
</button>
|
||||
<div class="flex items-center gap-3">
|
||||
<button onclick="window.invoiceView.syncFromQBO()" class="px-3 py-2 bg-indigo-600 text-white rounded-lg text-xs font-medium hover:bg-indigo-700">
|
||||
⟳ Sync from QBO
|
||||
</button>
|
||||
<button onclick="openInvoiceModal()" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-semibold shadow-md">
|
||||
+ New Invoice
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="invoice-toolbar"></div>
|
||||
|
||||
@@ -6,7 +6,7 @@ let filterCustomer = localStorage.getItem('inv_filterCustomer') || '';
|
||||
let filterStatus = localStorage.getItem('inv_filterStatus') || 'unpaid';
|
||||
let groupBy = localStorage.getItem('inv_groupBy') || 'none';
|
||||
let filterWorker = localStorage.getItem('inv_filterWorker') || '';
|
||||
let filterItemType = localStorage.getItem('inv_filterItemType') === 'true';
|
||||
let filterParts = localStorage.getItem('inv_filterParts') === 'true';
|
||||
let filterEmptyCost = localStorage.getItem('inv_filterEmptyCost') === 'true';
|
||||
|
||||
const OVERDUE_DAYS = 30;
|
||||
@@ -198,7 +198,7 @@ function saveSettings() {
|
||||
localStorage.setItem('inv_groupBy', groupBy);
|
||||
localStorage.setItem('inv_filterCustomer', filterCustomer);
|
||||
localStorage.setItem('inv_filterWorker', filterWorker);
|
||||
localStorage.setItem('inv_filterItemType', filterItemType);
|
||||
localStorage.setItem('inv_filterParts', filterParts);
|
||||
localStorage.setItem('inv_filterEmptyCost', filterEmptyCost);
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ function saveSettings() {
|
||||
export async function loadInvoices() {
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
if (filterItemType) {
|
||||
params.set('has_parts_or_subscription', 'true');
|
||||
if (filterParts) {
|
||||
params.set('has_parts', 'true');
|
||||
if (filterEmptyCost) params.set('empty_cost_only', 'true');
|
||||
}
|
||||
const qs = params.toString();
|
||||
@@ -611,17 +611,12 @@ export function injectToolbar() {
|
||||
</div>
|
||||
<div class="w-px h-8 bg-gray-300"></div>
|
||||
<div class="flex items-center gap-1 border border-gray-300 rounded-lg p-1 bg-gray-100">
|
||||
<button id="filter-item-type" onclick="window.invoiceView.toggleItemType()"
|
||||
class="px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${filterItemType ? 'bg-blue-500 text-white' : 'bg-white text-gray-600'}">Cost Items</button>
|
||||
<button id="filter-empty-cost" onclick="window.invoiceView.toggleEmptyCost()" style="${filterItemType ? '' : 'display:none'}"
|
||||
<button id="filter-item-type" onclick="window.invoiceView.toggleParts()"
|
||||
class="px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${filterParts ? 'bg-blue-500 text-white' : 'bg-white text-gray-600'}">Cost Items</button>
|
||||
<button id="filter-empty-cost" onclick="window.invoiceView.toggleEmptyCost()" style="${filterParts ? '' : 'display:none'}"
|
||||
class="px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${filterEmptyCost ? 'bg-blue-500 text-white' : 'bg-white text-gray-600'}">Empty cost only</button>
|
||||
</div>
|
||||
<div class="w-px h-8 bg-gray-300"></div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button onclick="window.invoiceView.syncFromQBO()" class="px-3 py-1.5 bg-indigo-600 text-white rounded-md text-xs font-medium hover:bg-indigo-700">
|
||||
⟳ Sync from QBO
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-auto flex items-center gap-4">
|
||||
<span id="last-sync-time" class="text-xs text-gray-400">...</span>
|
||||
<span class="text-sm text-gray-500">
|
||||
@@ -649,19 +644,19 @@ export function injectToolbar() {
|
||||
// ============================================================
|
||||
|
||||
export function setStatus(s) { filterStatus = s; saveSettings(); renderInvoiceView(); }
|
||||
export function toggleItemType() {
|
||||
filterItemType = !filterItemType;
|
||||
if (!filterItemType) filterEmptyCost = false;
|
||||
export function toggleParts() {
|
||||
filterParts = !filterParts;
|
||||
if (!filterParts) filterEmptyCost = false;
|
||||
saveSettings();
|
||||
const itemBtn = document.getElementById('filter-item-type');
|
||||
const emptyBtn = document.getElementById('filter-empty-cost');
|
||||
if (itemBtn) {
|
||||
itemBtn.className = filterItemType
|
||||
itemBtn.className = filterParts
|
||||
? 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-blue-500 text-white'
|
||||
: 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-white text-gray-600';
|
||||
}
|
||||
if (emptyBtn) {
|
||||
emptyBtn.style.display = filterItemType ? '' : 'none';
|
||||
emptyBtn.style.display = filterParts ? '' : 'none';
|
||||
emptyBtn.className = filterEmptyCost
|
||||
? 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-blue-500 text-white'
|
||||
: 'px-3 py-1.5 text-xs font-medium rounded-md transition-colors bg-white text-gray-600';
|
||||
@@ -669,7 +664,7 @@ export function toggleItemType() {
|
||||
loadInvoices();
|
||||
}
|
||||
export function toggleEmptyCost() {
|
||||
if (!filterItemType) return;
|
||||
if (!filterParts) return;
|
||||
filterEmptyCost = !filterEmptyCost;
|
||||
saveSettings();
|
||||
const btn = document.getElementById('filter-empty-cost');
|
||||
@@ -920,5 +915,5 @@ async function populateWorkerFilter() {
|
||||
|
||||
window.invoiceView = {
|
||||
viewPDF, viewHTML, syncFromQBO, resetQbo, markPaid, setEmailStatus, edit, remove,
|
||||
loadInvoices, renderInvoiceView, setStatus, toggleItemType, toggleEmptyCost, checkStripePayment, editSentDates ,_addSentDateRow, _saveSentDates
|
||||
loadInvoices, renderInvoiceView, setStatus, toggleParts, toggleEmptyCost, checkStripePayment, editSentDates ,_addSentDateRow, _saveSentDates
|
||||
};
|
||||
Reference in New Issue
Block a user