{{ define "title" -}}
    {{( pgettext "Add Products to Quotation" "title" )}}
{{- end }}

{{ define "breadcrumbs" -}}
    {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newQuoteProductsPage*/ -}}
    <nav>
        <p>
            <a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
            <a href="{{ companyURI "/quotes"}}">{{( pgettext "Quotations" "title" )}}</a> /
            {{ if eq .Form.Number "" }}
                <a>{{( pgettext "New Quotation" "title" )}}</a>
            {{ else }}
                <a>{{ .Form.Number }}</a>
            {{ end }}
        </p>
    </nav>
{{- end }}

{{ define "content" }}
    {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.newQuotationProductsPage*/ -}}
    <section id="quote-dialog-content" data-hx-target="this">
        <h2>{{(pgettext "Add Products to Quotation" "title")}}</h2>
        <form method="POST" action="{{ .Action }}" data-hx-boost="true" data-hx-select="#quote-dialog-content">
            {{ csrfToken }}

            {{- with .Form }}
                {{ template "hidden-select-field" .Customer }}
                {{ template "hidden-field" .Date }}
                {{ template "hidden-field" .Notes }}
                {{ template "hidden-field" .Tags }}

                {{- range $product := .Products }}
                    {{ template "hidden-field" .QuoteProductId }}
                    {{ template "hidden-field" .ProductId }}
                    {{ template "hidden-field" .Name }}
                    {{ template "hidden-field" .Description }}
                    {{ template "hidden-field" .Price }}
                    {{ template "hidden-field" .Quantity }}
                    {{ template "hidden-field" .Discount }}
                    {{ template "hidden-select-field" .Tax }}
                {{- end }}
            {{- end }}

            <table>
                <thead>
                <tr>
                    <th>{{( pgettext "All" "product" )}}</th>
                    <th>{{( pgettext "Name" "title" )}}</th>
                    <th>{{( pgettext "Price" "title" )}}</th>
                </tr>
                </thead>
                <tbody>
                {{ with .Products }}
                    {{- range . }}
                        <tr>
                            <td><input type="checkbox" name="slug" id="product-{{ .Slug }}" value="{{.Slug}}"></td>
                            <td><label for="product-{{ .Slug }}">{{ .Name }}</label></td>
                            <td class="numeric">{{ .Price | formatPrice }}</td>
                        </tr>
                    {{- end }}
                {{ else }}
                    <tr>
                        <td colspan="4">{{( gettext "No products added yet." )}}</td>
                    </tr>
                {{ end }}
                </tbody>
            </table>

            <fieldset>
                <button class="primary" type="submit"
                        name="action" value="add-products">{{( pgettext "Add products" "action" )}}</button>
            </fieldset>
        </form>
    </section>
{{- end }}