|
88 | 88 | let pending_order_store_in: string = $state(''); |
89 | 89 | let pending_order_team: Team | '' = $state(''); |
90 | 90 | let pending_order_reason = $state(''); |
91 | | - let change_order_ref_number: number | undefined = $state(undefined); |
| 91 | + let update_order_ref_number: number | undefined = $state(undefined); |
92 | 92 | let updated_order_status: OrderStatus['status'] | '' = $state(''); |
93 | 93 |
|
94 | 94 | function populatePending() { |
|
102 | 102 | pending_order_store_in = order.store_in; |
103 | 103 | pending_order_team = order.team; |
104 | 104 | pending_order_reason = order.reason; |
| 105 | + update_order_ref_number = order.reference_number; |
105 | 106 | } |
106 | 107 | } |
107 | 108 |
|
|
124 | 125 | } |
125 | 126 |
|
126 | 127 | function exportCSV() { |
127 | | - const header = ['Name', 'Vendor', 'Link', 'Count', 'Unit Cost', 'Store In', 'Team', 'Reason', 'Subtotal', 'Status']; |
| 128 | + const header = [ |
| 129 | + 'Name', |
| 130 | + 'Vendor', |
| 131 | + 'Link', |
| 132 | + 'Count', |
| 133 | + 'Unit Cost', |
| 134 | + 'Store In', |
| 135 | + 'Team', |
| 136 | + 'Reason', |
| 137 | + 'Subtotal', |
| 138 | + 'Status' |
| 139 | + ]; |
128 | 140 | const lines = [header.join(',')]; |
129 | 141 |
|
130 | 142 | for (const o of orders) { |
131 | 143 | const st = statuses |
132 | | - .filter(s => s.order_id === o.id) |
133 | | - .map(s => { |
| 144 | + .filter((s) => s.order_id === o.id) |
| 145 | + .map((s) => { |
134 | 146 | const date = s.date as Date; |
135 | 147 | const day = String(date.getDate()).padStart(2, '0'); |
136 | 148 | const month = String(date.getMonth() + 1).padStart(2, '0'); |
|
139 | 151 | }) |
140 | 152 | .join(','); |
141 | 153 | const sub = (o.count * (o.unit_cost as number)).toFixed(2); |
142 | | - lines.push([ |
143 | | - o.name, |
144 | | - o.vendor, |
145 | | - o.link, |
146 | | - o.count, |
147 | | - o.unit_cost, |
148 | | - o.store_in, |
149 | | - o.team, |
150 | | - o.reason, |
151 | | - sub, |
152 | | - st, |
153 | | - ].map(String).join(',')); |
| 154 | + lines.push( |
| 155 | + [o.name, o.vendor, o.link, o.count, o.unit_cost, o.store_in, o.team, o.reason, sub, st] |
| 156 | + .map(String) |
| 157 | + .join(',') |
| 158 | + ); |
154 | 159 | } |
155 | 160 |
|
156 | 161 | const csv = new Blob([lines.join('\n')], { type: 'text/csv' }); |
|
215 | 220 | <td class="order-name">{order.name}</td> |
216 | 221 | <td class="order-status"> |
217 | 222 | {#each statusesOf(order.id) as status} |
218 | | - <p><span class="italic">{status.status}</span>: {status.date.toLocaleString('en-US', { |
219 | | - weekday: 'short', |
220 | | - year: 'numeric', |
221 | | - month: 'long', |
222 | | - day: 'numeric' |
223 | | - })}</p> |
| 223 | + <p> |
| 224 | + <span class="italic">{status.status}</span>: {status.date.toLocaleString( |
| 225 | + 'en-US', |
| 226 | + { |
| 227 | + weekday: 'short', |
| 228 | + year: 'numeric', |
| 229 | + month: 'long', |
| 230 | + day: 'numeric' |
| 231 | + } |
| 232 | + )} |
| 233 | + </p> |
224 | 234 | {/each} |
225 | 235 | </td> |
226 | 236 | <td class="order-vendor">{order.vendor}</td> |
|
389 | 399 | team: pending_order_team, |
390 | 400 | reason: pending_order_reason, |
391 | 401 | store_in: pending_order_store_in, |
392 | | - change_order_ref_number |
| 402 | + change_order_ref_number: update_order_ref_number |
393 | 403 | }) |
394 | 404 | }); |
395 | 405 | if (response.ok) { |
|
409 | 419 | {:else} |
410 | 420 | {@render input()} |
411 | 421 |
|
412 | | - <label> |
413 | | - Ref Number |
414 | | - <input |
415 | | - type="number" |
416 | | - bind:value={change_order_ref_number} |
417 | | - placeholder="Reference Number" |
418 | | - /> |
419 | | - </label> |
420 | | - |
421 | 422 | <button |
422 | 423 | onclick={async () => { |
423 | 424 | if ( |
|
474 | 475 | <option value="Delivered">Delivered</option> |
475 | 476 | <option value="InStorage">In Storage</option> |
476 | 477 | </select> |
| 478 | + <label> |
| 479 | + Ref Number |
| 480 | + <input |
| 481 | + type="number" |
| 482 | + bind:value={update_order_ref_number} |
| 483 | + placeholder="Reference Number" |
| 484 | + /> |
| 485 | + </label> |
477 | 486 |
|
478 | 487 | <button |
479 | 488 | onclick={async () => { |
|
488 | 497 | }, |
489 | 498 | body: JSON.stringify({ |
490 | 499 | id: selectedOrderId, |
491 | | - status: updated_order_status |
| 500 | + status: updated_order_status, |
| 501 | + ref_number: update_order_ref_number |
492 | 502 | }) |
493 | 503 | }); |
494 | 504 | if (response.ok) { |
|
532 | 542 | {/if} |
533 | 543 | {:else if tabIndex === 4} |
534 | 544 | {#snippet cost(team: string)} |
535 | | - <p>{team} Total: {(expenditures[team] ?? 0).toLocaleString( |
536 | | - 'en-US', |
537 | | - { style: 'currency', currency: 'USD' } |
538 | | - )}</p> |
| 545 | + <p> |
| 546 | + {team} Total: {(expenditures[team] ?? 0).toLocaleString('en-US', { |
| 547 | + style: 'currency', |
| 548 | + currency: 'USD' |
| 549 | + })} |
| 550 | + </p> |
539 | 551 | {/snippet} |
540 | | - {@render cost("Software")} |
541 | | - {@render cost("Mechanical")} |
542 | | - {@render cost("Electrical")} |
543 | | - <p>Club Total: {(Object.values(expenditures).reduce((a, b) => a + b)).toLocaleString( |
544 | | - 'en-US', |
545 | | - { style: 'currency', currency: 'USD' } |
546 | | - )}</p> |
547 | | - |
548 | | - <section class="flex flex-col w-min" style:background-color="darkgray"> |
549 | | - <div class="relative flex flex-row gap-10 w-min pt-8 pr-8 pl-20" style:min-height="20rem"> |
| 552 | + {@render cost('Software')} |
| 553 | + {@render cost('Mechanical')} |
| 554 | + {@render cost('Electrical')} |
| 555 | + <p> |
| 556 | + Club Total: {Object.values(expenditures) |
| 557 | + .reduce((a, b) => a + b) |
| 558 | + .toLocaleString('en-US', { style: 'currency', currency: 'USD' })} |
| 559 | + </p> |
| 560 | + |
| 561 | + <section class="flex w-min flex-col" style:background-color="darkgray"> |
| 562 | + <div class="relative flex w-min flex-row gap-10 pl-20 pr-8 pt-8" style:min-height="20rem"> |
550 | 563 | {#each { length: Math.floor(maxExpenditure / costIncrement) + 1 } as _, i} |
551 | | - <div class="absolute flex flex-row" style:width={"calc(100% - 5rem)"} style:right="1rem" style:bottom={`calc((100% - 2rem) * ${i*costIncrement / maxExpenditure})`}> |
| 564 | + <div |
| 565 | + class="absolute flex flex-row" |
| 566 | + style:width={'calc(100% - 5rem)'} |
| 567 | + style:right="1rem" |
| 568 | + style:bottom={`calc((100% - 2rem) * ${(i * costIncrement) / maxExpenditure})`} |
| 569 | + > |
552 | 570 | <div class="w-full border-t-2 border-black"></div> |
553 | | - <p class="absolute mr-2" style:bottom="-0.75rem" style:right="100%">${i * costIncrement}</p> |
| 571 | + <p class="absolute mr-2" style:bottom="-0.75rem" style:right="100%"> |
| 572 | + ${i * costIncrement} |
| 573 | + </p> |
554 | 574 | </div> |
555 | 575 | {/each} |
556 | 576 |
|
557 | 577 | {#snippet bar(team: string)} |
558 | | - <div class="flex flex-col" style:z-index=1> |
559 | | - <div class="flex flex-col justify-end flex-grow items-center"> |
560 | | - <div style:background-color="darkred" style:height={`calc(100% * ${expenditures[team] / maxExpenditure})`} style:width="3rem"> |
561 | | - </div> |
| 578 | + <div class="flex flex-col" style:z-index="1"> |
| 579 | + <div class="flex flex-grow flex-col items-center justify-end"> |
| 580 | + <div |
| 581 | + style:background-color="darkred" |
| 582 | + style:height={`calc(100% * ${expenditures[team] / maxExpenditure})`} |
| 583 | + style:width="3rem" |
| 584 | + ></div> |
562 | 585 | </div> |
563 | 586 | </div> |
564 | 587 | {/snippet} |
565 | | - {@render bar("Software")} |
566 | | - {@render bar("Mechanical")} |
567 | | - {@render bar("Electrical")} |
| 588 | + {@render bar('Software')} |
| 589 | + {@render bar('Mechanical')} |
| 590 | + {@render bar('Electrical')} |
568 | 591 | </div> |
569 | 592 | <div class="flex flex-row gap-4" style:margin-left="4.5rem"> |
570 | 593 | <p>Software</p> |
|
0 commit comments