Files
visa/templates/company.html
T
grabowski 2a6e972b68
CI / secret scan (push) Successful in 4s
CI / fmt, clippy, tests (push) Successful in 22s
A company's office: its GPS position and a photo
The company form has a field for the office's GPS position (migration
0004, column companies.office_gps). It takes what people have at hand:
the numbers Google Maps copies, a link to the place on Google Maps or
OpenStreetMap, a geo: URI, or degrees, minutes and seconds. It keeps
decimal degrees with six decimals and refuses a position outside Thailand,
which catches a swapped pair; a short maps.app.goo.gl link is refused with
a hint, as it holds no position (src/gps.rs, with unit tests).

The company's page has an Office card: the position with links that open
it on OpenStreetMap and Google Maps, the newest photo of the office, and a
strip that uploads a photo (kind "Photo of the office") and returns to the
card. The photos are documents like any other: encrypted on the server and
audited. A refused photo shows its errors on the card only; office photos
that are PDFs are counted under Company documents.

The demo company has a position. Tests: the position read from a link,
from degrees, minutes and seconds, the three refusals, the audit entry and
its removal; a photo uploaded from the card, shown, and its errors placed.
2026-11-18 11:56:26 +07:00

122 lines
7.6 KiB
HTML

{% extends "base.html" %}
{% import "_documents.html" as dm %}
{% block main %}
<div class="phead">
<div class="crumbs"><a href="/companies">Companies</a></div>
<div class="pagehead">
<h1>{{ c.name }}</h1>
<div class="actions">
<a class="btn sm" href="/companies/{{ c.id }}/edit">Edit</a>
{% if c.archived %}
<form method="post" action="/companies/{{ c.id }}/restore" class="inline-form"><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm">Restore</button></form>
{% else %}
<form method="post" action="/companies/{{ c.id }}/archive" class="inline-form" data-confirm="Archive {{ c.name }}? It is no longer offered as an employer; existing records keep it."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Archive</button></form>
{% endif %}
</div>
</div>
<p class="meta">
{%- if c.name_th %}{{ c.name_th }}{% endif %}
{%- if c.registration_no %}{% if c.name_th %}<span class="sep">·</span>{% endif %}registration <span class="mono">{{ c.registration_no }}</span>{% endif %}
</p>
</div>
{% if c.archived %}
<div class="notice warn">Archived on {{ c.archived_on }}. It is no longer offered as an employer; Restore brings it back.</div>
{% endif %}
<div class="cols">
<section class="card" id="details">
<header><h2>Company details</h2></header>
<dl class="kv">
<dt>Name in English</dt><dd>{{ c.name }}</dd>
<dt>Name in Thai</dt><dd>{% if c.name_th %}{{ c.name_th }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Registration number</dt><dd>{% if c.registration_no %}<span class="mono">{{ c.registration_no }}</span>{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Type of business</dt><dd>{% if c.business %}{{ c.business }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Address</dt><dd>{% if c.address %}{{ c.address }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Phone</dt><dd>{% if c.phone %}{{ c.phone }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Email</dt><dd>{% if c.email %}{{ c.email }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Authorized director</dt><dd>{% if c.signatory %}{{ c.signatory }}{% if c.signatory_position %}, {{ c.signatory_position }}{% endif %}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
{% if c.notes %}<dt>Notes</dt><dd class="pre">{{ c.notes }}</dd>{% endif %}
</dl>
</section>
<section class="card" id="people">
<header><h2>People employed</h2>{% if employees %}<a class="btn sm ghost" href="/people?company={{ c.id }}">In the people list</a>{% endif %}</header>
{% for e in employees %}
<div class="item">
<div class="row"><a class="strong" href="/people/{{ e.id }}">{{ e.name }}</a><span class="muted">{{ e.nationality }}</span></div>
<div class="row">
<span class="chip {{ e.permit.level }}">{{ e.permit.label }}</span>
<form method="post" action="/companies/{{ c.id }}/employees/{{ e.id }}/remove" class="inline-form" data-confirm="Remove {{ e.name }} from the people employed here? The person's record stays."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="linkbtn">Remove</button></form>
</div>
</div>
{% else %}
<p class="empty-inline">No one is recorded as employed here yet.</p>
{% endfor %}
{% if candidates and not c.archived %}
<form method="post" action="/companies/{{ c.id }}/employees" class="hire" id="hire-form">
<input type="hidden" name="csrf" value="{{ csrf }}">
<label for="f-person">Add a person</label>
<div class="hire-row">
<select id="f-person" name="person" required>
<option value="">Choose a person</option>
{%- for o in candidates %}
<option value="{{ o[0] }}">{{ o[1] }}</option>
{%- endfor %}
</select>
<button type="submit" class="btn sm">Add</button>
</div>
<p class="hint">This makes the company the person's employer. Someone new is first added under People.</p>
</form>
{% endif %}
</section>
<section class="card span2" id="office">
<header><h2>Office</h2><a class="btn sm ghost" href="/companies/{{ c.id }}/edit#f-office_gps">{% if c.gps %}Change the position{% else %}Add the GPS position{% endif %}</a></header>
<div class="office">
<div class="office-pic">
{%- if office.photo %}
<a href="{{ office.photo.href }}" target="_blank" rel="noopener"><img src="{{ office.photo.href }}" alt="Photo of the office of {{ c.name }}"></a>
<p class="muted small">{% if office.photo.dated_on %}Taken {{ office.photo.dated_on }}{% else %}Added {{ office.photo.uploaded }}{% endif %}{% if office.more %} · {{ office.more }} more under <a href="#documents">Company documents</a>{% endif %}</p>
{%- else %}
<div class="office-none">No photo of the office yet</div>
{%- if office.more %}
<p class="muted small">{{ office.more }} as PDF under <a href="#documents">Company documents</a></p>
{%- endif %}
{%- endif %}
</div>
<div class="office-info">
<dl class="kv">
<dt>GPS position</dt>
<dd>{% if c.gps %}<span class="mono">{{ c.gps }}</span>{% if c.osm %}<span class="maplinks"><a href="{{ c.osm }}" target="_blank" rel="noopener noreferrer">OpenStreetMap</a><a href="{{ c.gmaps }}" target="_blank" rel="noopener noreferrer">Google Maps</a></span>{% endif %}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
</dl>
<p class="hint">The position and the photo help the officers who visit the workplace, and go into the extension packs of the people employed here.</p>
{%- if office.files_on %}
<form method="post" action="/companies/{{ c.id }}/documents" enctype="multipart/form-data" class="upload office-up" id="office-upload">
<input type="hidden" name="csrf" value="{{ csrf }}">
<input type="hidden" name="kind" value="office-photo">
<input type="hidden" name="back" value="office">
{%- if office.errors %}
<div class="notice warn">Nothing was uploaded. {{ office.errors.file or office.errors.kind or office.errors.note or "Choose the photo again." }}</div>
{%- endif %}
<div class="drop{% if office.errors.file %} has-err{% endif %}" data-max="{{ office.file_limit }}">
<input type="file" id="f-office-file" name="file" required accept="image/jpeg,image/png,image/webp" aria-describedby="h-office-file">
<span class="drop-icon" aria-hidden="true">+</span>
<label for="f-office-file"><b>{% if office.photo %}Add a newer photo{% else %}Add a photo of the office{% endif %}</b> or drop it here</label>
<span class="drop-names" data-drop-names></span>
<span class="hint" id="h-office-file">JPEG, PNG or WebP, up to {{ office.file_limit_mb }} MB</span>
</div>
<button type="submit" class="btn pri">Upload</button>
</form>
{%- endif %}
</div>
</div>
</section>
<section class="card span2" id="documents">
<header><h2>Company documents</h2><span class="muted small">for the extension packs of the people employed here</span></header>
{{ dm.upload(upload, csrf, person=false) }}
{%- if docs %}
{{ dm.table(docs, person=false) }}
{%- else %}
<p class="empty-inline">No company documents yet: the company certificate and the list of shareholders (certified within six months), the tax and social security returns, a map and photos of the office.</p>
{%- endif %}
</section>
</div>
{% endblock %}