2023-02-11 21:16:48 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{( pgettext "New Invoice" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "breadcrumbs" -}}
|
2023-03-13 14:00:35 +00:00
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newInvoicePage*/ -}}
|
2023-04-02 14:10:13 +00:00
|
|
|
<nav data-hx-target="main" data-hx-boost="true">
|
2023-02-11 21:16:48 +00:00
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a href="{{ companyURI "/invoices"}}">{{( pgettext "Invoices" "title" )}}</a> /
|
|
|
|
<a>{{( pgettext "New Invoice" "title" )}}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
2023-03-20 12:09:52 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" }}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newInvoicePage*/ -}}
|
2023-03-31 11:01:26 +00:00
|
|
|
<section class="dialog-content" id="invoice-dialog-content" data-hx-target="this">
|
2023-02-11 21:16:48 +00:00
|
|
|
<h2>{{(pgettext "New Invoice" "title")}}</h2>
|
2023-03-31 11:01:26 +00:00
|
|
|
<form method="POST" action="{{ companyURI "/invoices" }}" data-hx-boost="true" data-hx-select="#invoice-dialog-content">
|
2023-02-11 21:16:48 +00:00
|
|
|
{{ csrfToken }}
|
|
|
|
|
2023-02-23 14:31:57 +00:00
|
|
|
{{ with .Form -}}
|
Show the duplicate invoice form in a dialog
Had to add a new hidden field to the form to know whether, when the
request is HTMx-triggered, to refresh the page, as i do when duplicating
from the index, or redirect the client to the new invoice’s view page,
but only if i was duplicating from that same page, not the index.
Since i now have to target main when redirecting to the view page, so
i had to add a location structure with the required json fields and all
that, when “refreshing” i actually tell HTMx to open the index page
again, which seems faster, now that i am used to boosted links.
2023-04-04 12:39:55 +00:00
|
|
|
{{ template "hidden-field" .Location }}
|
2023-03-13 14:00:35 +00:00
|
|
|
{{ template "hidden-select-field" .InvoiceStatus }}
|
2023-02-23 14:31:57 +00:00
|
|
|
{{ template "select-field" .Customer }}
|
|
|
|
{{ template "input-field" .Date }}
|
2023-03-19 22:11:40 +00:00
|
|
|
{{ template "tags-field" .Tags }}
|
2023-03-04 21:15:52 +00:00
|
|
|
{{ template "select-field" .PaymentMethod }}
|
2023-03-10 13:02:55 +00:00
|
|
|
{{ template "input-field" .Notes }}
|
2023-02-11 21:16:48 +00:00
|
|
|
|
2023-02-23 14:31:57 +00:00
|
|
|
{{- range $product := .Products }}
|
2023-04-24 00:00:38 +00:00
|
|
|
{{ template "invoice-product-form" . }}
|
2023-02-23 14:31:57 +00:00
|
|
|
{{- end }}
|
2023-02-11 21:16:48 +00:00
|
|
|
{{- end }}
|
|
|
|
|
2023-04-24 00:00:38 +00:00
|
|
|
<table id="invoice-summary">
|
2023-02-23 14:31:57 +00:00
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{(pgettext "Subtotal" "title")}}</th>
|
|
|
|
<td class="numeric">{{ .Subtotal | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- range $tax := .Taxes }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{ index . 0 }}</th>
|
|
|
|
<td class="numeric">{{ index . 1 | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{(pgettext "Total" "title")}}</th>
|
|
|
|
<td class="numeric">{{ .Total | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2023-02-11 21:16:48 +00:00
|
|
|
<fieldset>
|
2023-02-27 12:13:28 +00:00
|
|
|
<button formnovalidate formaction="{{ companyURI "/invoices/new" }}"
|
|
|
|
name="action" value="select-products"
|
2023-04-24 00:00:38 +00:00
|
|
|
data-hx-get="{{ companyURI "/invoices/product-form" }}"
|
|
|
|
data-hx-target="#invoice-summary" data-hx-swap="beforebegin"
|
|
|
|
data-hx-select="unset"
|
|
|
|
data-hx-vals="js:{index: document.querySelectorAll('.new-invoice-product').length}"
|
2023-02-14 11:55:19 +00:00
|
|
|
type="submit">{{( pgettext "Add products" "action" )}}</button>
|
2023-02-27 12:13:28 +00:00
|
|
|
<button formnovalidate formaction="{{ companyURI "/invoices/new" }}"
|
2023-04-24 00:00:38 +00:00
|
|
|
id="recompute-button"
|
2023-02-27 12:13:28 +00:00
|
|
|
name="action" value="update"
|
2023-02-14 11:55:19 +00:00
|
|
|
type="submit">{{( pgettext "Update" "action" )}}</button>
|
2023-02-12 20:06:48 +00:00
|
|
|
<button class="primary" name="action" value="add"
|
|
|
|
type="submit">{{( pgettext "New invoice" "action" )}}</button>
|
2023-02-11 21:16:48 +00:00
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</section>
|
2023-04-24 00:00:38 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
document.body.addEventListener('recompute', function () {
|
|
|
|
document.getElementById('recompute-button').click();
|
|
|
|
});
|
|
|
|
</script>
|
2023-02-11 21:16:48 +00:00
|
|
|
{{- end }}
|