🕒 Timesheet List

Manage and track timesheets for staff members.

{ currentSearchTerm = (e.target as HTMLInputElement).value.toLowerCase(); fetchTimeSheets(currentVillaFilter, currentSearchTerm); }} />
{#each columns as col} {#if col.key === "villa_name"} {:else} {/if} {/each} {#each allRows as row} {#each columns as col} {#if col.key === "name"} {:else if col.key === "approval"} {:else if col.key === "approved_by"} {:else if col.key === "approved_date"} {:else if col.key === "total_hours_work"} {:else if col.key === "created_at"} {:else if col.key === "villa_name"} {:else if col.key === "staff_id"} {:else if col.key === "remarks"} {:else if col.key === "actions"} {:else if col.key === "date_in" || col.key === "date_out"} {:else} {/if} {/each} {/each}
toggleSort(col.key)} > {col.title} {#if sortColumn === col.key} {sortOrder === 'asc' ? ' 🔼' : ' 🔽'} {/if} toggleSort(col.key)} > {col.title} {#if sortColumn === col.key} {sortOrder === 'asc' ? ' 🔼' : ' 🔽'} {/if}
{row[col.key]} {row[col.key]} {#if row.approval === "PENDING"} {/if} {row[col.key] || "Not Approved"} {row[col.key] && !isNaN(new Date(row[col.key] as string | number | Date).getTime()) ? new Date(row[col.key] as string | number | Date).toLocaleString() : "N/A"} {row[col.key].toFixed(2)} hours {row[col.key] !== undefined ? new Date(row[col.key] as string | number | Date).toLocaleString() : "N/A"} {row[col.key] || "Unknown Villa"} {row[col.key] || "Unknown Staff"} {row[col.key] || "No remarks"} {row[col.key] ? new Date(row[col.key]).toLocaleString() : "N/A"} {row[col.key as keyof TimesheetDisplay]}
Showing {(currentPage - 1) * rowsPerPage + 1}– {Math.min(currentPage * rowsPerPage, totalItems)} of {totalItems} items
{#each pageRange(totalPages, currentPage) as page} {#if page === "..."} ... {:else} {/if} {/each}
{#if showModal}

{isEditing ? "Edit Timesheet" : "New Timesheet Entry"}

{form.total_work_hour}
{/if}