Add the country name to the footer’s address

Customer requested it
This commit is contained in:
jordi fita mas 2023-12-20 20:22:32 +01:00
parent 907d9844d3
commit b6c4eb790f
2 changed files with 9 additions and 3 deletions

View File

@ -54,7 +54,7 @@ func (p *PublicPage) Setup(r *http.Request, user *auth.User, company *auth.Compa
`, user.Locale.Language, company.ID), `, user.Locale.Language, company.ID),
} }
if err := p.CompanyAddress.FillFromDatabase(r.Context(), conn, company); err != nil { if err := p.CompanyAddress.FillFromDatabase(r.Context(), conn, user, company); err != nil {
panic(err) panic(err)
} }
} }
@ -105,30 +105,35 @@ type address struct {
PostalCode string PostalCode string
Province string Province string
City string City string
Country string
Phone string Phone string
Email string Email string
RTCNumber string RTCNumber string
} }
func (addr *address) FillFromDatabase(ctx context.Context, conn *database.Conn, company *auth.Company) error { func (addr *address) FillFromDatabase(ctx context.Context, conn *database.Conn, user *auth.User, company *auth.Company) error {
row := conn.QueryRow(ctx, ` row := conn.QueryRow(ctx, `
select trade_name select trade_name
, address , address
, postal_code , postal_code
, province , province
, city , city
, coalesce(country_i18n.name, country.name) as country_name
, phone::text , phone::text
, email::text , email::text
, rtc_number , rtc_number
from company from company
join country using (country_code)
left join country_i18n on country.country_code = country_i18n.country_code and country_i18n.lang_tag = $2
where company_id = $1 where company_id = $1
`, company.ID) `, company.ID, user.Locale.Language)
return row.Scan( return row.Scan(
&addr.TradeName, &addr.TradeName,
&addr.Address, &addr.Address,
&addr.PostalCode, &addr.PostalCode,
&addr.Province, &addr.Province,
&addr.City, &addr.City,
&addr.Country,
&addr.Phone, &addr.Phone,
&addr.Email, &addr.Email,
&addr.RTCNumber, &addr.RTCNumber,

View File

@ -114,6 +114,7 @@
<address> <address>
{{ .Address }}<br> {{ .Address }}<br>
{{ .PostalCode}} · {{ .City }} · {{ .Province }}<br> {{ .PostalCode}} · {{ .City }} · {{ .Province }}<br>
{{ .Country }}<br>
<abbr>T</abbr> <a href="tel:{{ replaceAll .Phone " " "" }}">{{ .Phone }}</a><br> <abbr>T</abbr> <a href="tel:{{ replaceAll .Phone " " "" }}">{{ .Phone }}</a><br>
<a href="mailto:{{ .Email }}">{{ .Email }}</a> <a href="mailto:{{ .Email }}">{{ .Email }}</a>
</address> </address>