rev timesheet & project
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { onMount } from "svelte";
|
||||
import { supabase } from "$lib/supabaseClient";
|
||||
import { getSessionAuthId } from "$lib/utils/authUtil";
|
||||
import CurrencyInput from "$lib/CurrencyInput.svelte";
|
||||
|
||||
|
||||
type PurchaseOrderInsert = {
|
||||
@@ -77,9 +78,10 @@
|
||||
};
|
||||
|
||||
const columns: columns[] = [
|
||||
|
||||
{ key: "purchase_order_number", title: "PO Number" },
|
||||
{ key: "issue_name", title: "Issue Name" },
|
||||
{ key: "requested_date", title: "Requested Date" },
|
||||
{ key: "purchase_order_number", title: "PO Number" },
|
||||
{ key: "po_status", title: "PO Status" },
|
||||
{ key: "villa_data", title: "Villa Name" },
|
||||
{ key: "po_item", title: "PO Product" },
|
||||
@@ -224,6 +226,8 @@
|
||||
acknowledged_by: "",
|
||||
acknowledged_date: ""
|
||||
};
|
||||
let selectedVillaId: string | null = null;
|
||||
let searchTerm: string = "";
|
||||
let showPreparedModal = false;
|
||||
let selectedPO = null;
|
||||
let preparedByOptions: any[] = [];
|
||||
@@ -244,7 +248,8 @@
|
||||
approved_vendor: "",
|
||||
approved_price: 0,
|
||||
total_approved_order_amount: 0
|
||||
};
|
||||
};
|
||||
let formattedPrice = "";
|
||||
let showReceivedModal = false;
|
||||
let receivedForm = {
|
||||
po_number: "",
|
||||
@@ -273,6 +278,11 @@
|
||||
currentPage * rowsPerPage,
|
||||
);
|
||||
$: currentPage = 1; // Reset to first page when allRows changes
|
||||
$: formattedPrice = preparedForm.q1_vendor_price.toLocaleString("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
|
||||
// Function to format numbers as ordinal (1st, 2nd, 3rd, etc.)
|
||||
function ordinal(num: number) {
|
||||
@@ -682,7 +692,7 @@
|
||||
let query = supabase
|
||||
.from("vb_purchaseorder_data")
|
||||
.select("*")
|
||||
.order(sort || "created_at", { ascending: order === "asc" })
|
||||
.order(sort || "purchase_order_number", { ascending: order === "desc" })
|
||||
.range(offset, offset + limit - 1);
|
||||
|
||||
if (filter) {
|
||||
@@ -1065,7 +1075,7 @@
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
{#each columns as col}
|
||||
{#if col.key === "issue_name"}
|
||||
{#if col.key === "purchase_order_number"}
|
||||
<th
|
||||
class="sticky left-0 px-4 py-3 text-left font-semibold text-gray-700 uppercase tracking-wider whitespace-nowrap"
|
||||
style="background-color: #f0f8ff; z-index: 10;"
|
||||
@@ -1098,10 +1108,10 @@
|
||||
<td class="px-4 py-2 text-gray-700 max-w-xs whitespace-normal align-top break-words">
|
||||
{row[col.key] || "—"}
|
||||
</td>
|
||||
{:else if col.key === "issue_name"}
|
||||
{:else if col.key === "purchase_order_number"}
|
||||
<td class="sticky left-0 px-4 py-2 font-medium text-blue-600 max-w-xs whitespace-normal align-top break-words"
|
||||
style="background-color: #f0f8ff; cursor: pointer;">
|
||||
{row.issue_name || "—"}
|
||||
{row.purchase_order_number || "—"}
|
||||
</td>
|
||||
{:else if col.key === "prepared"}
|
||||
<td class="px-4 py-2 text-center">
|
||||
@@ -1209,16 +1219,7 @@
|
||||
>
|
||||
Payment
|
||||
</button>
|
||||
</td>
|
||||
{:else if col.key === "actions"}
|
||||
<td class="px-4 py-2">
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-blue-700"
|
||||
on:click={() => openEditModal(row)}
|
||||
>
|
||||
✏️ Edit
|
||||
</button>
|
||||
|
||||
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded bg-teal-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-teal-700 disabled:bg-gray-400 disabled:cursor-not-allowed"
|
||||
on:click={() => printPO(row)}
|
||||
@@ -1232,6 +1233,16 @@
|
||||
🖨️ Print
|
||||
{/if}
|
||||
</button>
|
||||
</td>
|
||||
{:else if col.key === "actions"}
|
||||
<td class="px-4 py-2">
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-blue-700"
|
||||
on:click={() => openEditModal(row)}
|
||||
>
|
||||
✏️ Edit
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded bg-red-600 px-3 py-1.5 text-white text-xs font-medium hover:bg-red-700"
|
||||
on:click={() => deleteProject(row.id)}
|
||||
@@ -1567,8 +1578,23 @@
|
||||
<option value={v.name}>{v.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<input type="number" bind:value={preparedForm.q1_vendor_price} placeholder="Q1 Vendor Price" class="w-full border p-2" />
|
||||
|
||||
<CurrencyInput bind:value={preparedForm.q1_vendor_price} label="Q1 Vendor Price" />
|
||||
<label>Q2 Vendor</label>
|
||||
<select bind:value={preparedForm.q2_vendor} class="w-full border p-2">
|
||||
<option value="" disabled>Select Vendor</option>
|
||||
{#each vendorOptions as v}
|
||||
<option value={v.name}>{v.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<CurrencyInput bind:value={preparedForm.q2_vendor_price} label="Q1 Vendor Price" />
|
||||
<label>Q3 Vendor</label>
|
||||
<select bind:value={preparedForm.q3_vendor} class="w-full border p-2">
|
||||
<option value="" disabled>Select Vendor</option>
|
||||
{#each vendorOptions as v}
|
||||
<option value={v.name}>{v.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<CurrencyInput bind:value={preparedForm.q3_vendor_price} label="Q1 Vendor Price" />
|
||||
<!-- Repeat for Q2, Q3 -->
|
||||
<!-- Approved -->
|
||||
<label>Approved Quantity</label>
|
||||
@@ -1581,9 +1607,11 @@
|
||||
<option value={v.name}>{v.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
|
||||
<label>Approved Price</label>
|
||||
<input type="number" bind:value={preparedForm.approved_price} on:input={() => updateTotalAmount()} class="w-full border p-2" />
|
||||
<CurrencyInput
|
||||
bind:value={preparedForm.approved_price}
|
||||
label="Approved Price"
|
||||
onInput={updateTotalAmount}
|
||||
/>
|
||||
|
||||
<label>Total Approved Order Amount</label>
|
||||
<input type="number" value={preparedForm.total_approved_order_amount} disabled class="w-full border p-2 bg-gray-100" />
|
||||
|
||||
Reference in New Issue
Block a user