Files
grabowski d0e13dffd2
CI / secret scan (push) Successful in 6s
CI / fmt, clippy, tests (push) Successful in 1m0s
CI / release (push) Skipped
Agreements the client signs on the link (task 7.6)
Built into the app rather than a separate signing service: any number of
agreements (the processing of the client's data first, legal services
and consultations later), each in versions whose text never changes.

- Staff (Agreements in the sidebar, src/web/agreements.rs): paste the
  lawyers' text (empty line = paragraph, "# " heading, "- " list item),
  preview it as the client reads it, publish version 1; a changed text is
  the next version, the same text again is refused, and the database
  refuses any change to a published one (migrations/0007, trigger).
  Switch an agreement off and links stop asking for it.
- Client: every active agreement is the first step of every link. The
  client reads it, ticks that they accept, types their name and signs
  with a finger or the mouse (static/signature.js; a PNG of the pad). A
  text changed while they read it is refused. A new version is asked for
  again at the next link.
- The signed copy (src/agreements/pdf.rs, Sarabun so Thai prints, long
  Thai words cut without parting marks from their letter): the text, the
  name, the record, the time, the drawing, the link, the forwarded
  address, the browser and the text's SHA-256; kept as the person's
  encrypted document of kind "agreement", all in one transaction with the
  signature and the audit rows (actor link N).
- The person's page shows each agreement's state (signed, not signed, to
  sign again) and every signed copy.
- Phones: the section row now scrolls sideways instead of wrapping, so it
  keeps one height with five sections and Sign out.
- Demo data: an invented agreement with a Thai paragraph.

Checks: fmt, clippy; 105 unit and 56 integration tests (tests/agreements.rs:
versions that never change, signing with a drawing, address and browser
recorded, the PDF, signing again after a change, a stale version refused,
switched off); layout check light/dark desk/phone on the agreement pages,
the client's agreement page, the person page and the people list: no
problems; a drawn signature in Edge at 390x844 signed and printed.
2026-11-20 20:18:59 +07:00

116 lines
8.2 KiB
HTML

{% extends "base.html" %}
{% block main %}
{% include "_person_head.html" %}
<div class="cols">
{% include "_deadlines.html" %}
<section class="card" id="details">
<header><h2>Personal details</h2><a class="btn sm" href="/people/{{ p.id }}/edit">Edit</a></header>
<dl class="kv">
<dt>Surname</dt><dd>{{ p.surname }}</dd>
<dt>Given names</dt><dd>{{ p.given }}</dd>
{% if p.title %}<dt>Title</dt><dd>{{ p.title }}</dd>{% endif %}
<dt>Sex</dt><dd>{% if p.sex %}{{ p.sex }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Date of birth</dt><dd>{% if p.dob %}{{ p.dob }} <span class="muted">({{ p.age }} years)</span>{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Place of birth</dt><dd>{% if p.place_of_birth %}{{ p.place_of_birth }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Nationality</dt><dd>{% if p.nationality %}{{ p.nationality_name }} <span class="muted mono">{{ p.nationality }}</span>{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Occupation</dt><dd>{% if p.occupation %}{{ p.occupation }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Employer</dt><dd>{% if p.employer %}<a href="/companies/{{ p.employer_id }}">{{ p.employer }}</a>{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Phone</dt><dd>{% if p.phone %}{{ p.phone }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>Email</dt><dd>{% if p.email %}{{ p.email }}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
{% if p.notes %}<dt>Notes</dt><dd class="pre">{{ p.notes }}</dd>{% endif %}
</dl>
</section>
<section class="card" id="passports">
<header><h2>Passport</h2><a class="btn sm" href="/people/{{ p.id }}/passports/new">+ New passport</a></header>
{% for pp in passports %}
<div class="item{% if not pp.current %} old{% endif %}">
<div class="row">
<span class="mono strong">{{ pp.number }}</span>
<span class="muted">{{ pp.country_name }}</span>
{% if pp.current %}<span class="tag">current</span>{% else %}<span class="tag plain">previous</span>{% endif %}
</div>
<dl class="kv">
<dt>Issued</dt><dd>{% if pp.issued_on %}{{ pp.issued_on }}{% else %}<span class="muted">date not recorded</span>{% endif %}{% if pp.issued_at %}, {{ pp.issued_at }}{% endif %}</dd>
<dt>Valid until</dt><dd>{{ pp.expires_on }}{% if pp.status %} <span class="chip {{ pp.status.level }}">{{ pp.status.label }}</span>{% endif %}</dd>
<dt>Zone</dt><dd>{% if pp.has_mrz %}read, check digits matched{% else %}<span class="muted">typed in by hand</span>{% endif %}</dd>
</dl>
<div class="rowactions"><a href="/people/{{ p.id }}/passports/{{ pp.id }}/edit">Edit</a>{% for d in docs["passports:" ~ pp.id] %}<a class="doclink" href="{{ d.href }}" target="_blank" rel="noopener">{{ d.label }}</a>{% endfor %}<a href="/people/{{ p.id }}/documents?for=passports:{{ pp.id }}#upload">+ Document</a></div>
</div>
{% else %}
<p class="empty-inline">No passport recorded yet. Add it with + New passport; the two lines at the bottom of the photo page fill the form in.</p>
{% endfor %}
</section>
<section class="card" id="addresses">
<header><h2>Address in Thailand</h2><a class="btn sm" href="/people/{{ p.id }}/addresses/new">+ New address</a></header>
{% for a in addresses %}
<div class="item{% if not a.current %} old{% endif %}">
<div class="row">
{% if a.current %}<span class="tag">current</span>{% else %}<span class="tag plain">earlier</span>{% endif %}
<span class="muted small">{% if a.moved_in_on %}since {{ a.moved_in_on }}{% endif %}{% if a.moved_out_on %} until {{ a.moved_out_on }}{% endif %}</span>
</div>
<p class="addr">{{ a.line }}</p>
<dl class="kv">
<dt>House master</dt><dd>{% if a.house_master %}{{ a.house_master }}{% if a.house_master_phone %}, {{ a.house_master_phone }}{% endif %}{% else %}<span class="muted">not recorded</span>{% endif %}</dd>
<dt>TM.30</dt><dd>{% if a.tm30_reported_on %}reported {{ a.tm30_reported_on }}{% if a.tm30_receipt_no %}, receipt <span class="mono">{{ a.tm30_receipt_no }}</span>{% endif %}{% else %}<span class="muted">no receipt recorded</span>{% endif %}
{% if a.tm30 %}<div><span class="chip {{ a.tm30.level }}">{{ a.tm30.label }}</span></div>{% endif %}</dd>
</dl>
<div class="rowactions"><a href="/people/{{ p.id }}/addresses/{{ a.id }}/edit">Edit</a>{% for d in docs["addresses:" ~ a.id] %}<a class="doclink" href="{{ d.href }}" target="_blank" rel="noopener">{{ d.label }}</a>{% endfor %}<a href="/people/{{ p.id }}/documents?for=addresses:{{ a.id }}#upload">+ Document</a></div>
</div>
{% else %}
<p class="empty-inline">No address recorded yet. The TM.30 receipt of the current address goes with it.</p>
{% endfor %}
</section>
<section class="card" id="client-link">
<header><h2>Client link</h2>
<form method="post" action="/people/{{ p.id }}/links" class="inline-form"{% if client_links and client_links[0].usable %} data-confirm="Make a new link? The open one stops working."{% endif %}><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm" id="make-link">{% if client_links %}New link{% else %}Make a link{% endif %}</button></form>
</header>
{% for l in client_links %}
<div class="item{% if not loop.first %} old{% endif %}">
<div class="row">
<span class="chip {{ l.level }}">{{ l.state }}</span>
<span class="muted small">made {{ l.made }} by {{ l.by }}{% if l.usable %}, works until {{ l.until }}{% endif %}</span>
</div>
<dl class="kv">
{% if l.opened %}<dt>Opened</dt><dd>{{ l.opened }}</dd>{% endif %}
{% if l.sent %}<dt>Sent</dt><dd>{{ l.sent }}</dd>{% endif %}
{% if l.closed %}<dt>Closed</dt><dd>{{ l.closed }}</dd>{% endif %}
{% if l.changes %}<dt>Changed</dt><dd><ul class="changes">{% for c in l.changes %}<li><a href="{{ c.href }}">{{ c.label }}</a>{% if c.fields %} <span class="muted">({{ c.fields }})</span>{% endif %}</li>{% endfor %}</ul></dd>{% endif %}
</dl>
{% if l.changes %}<p class="hint">The client's entries went straight into the record: check them against the papers.</p>{% endif %}
{% if l.usable %}<div class="rowactions"><form method="post" action="/people/{{ p.id }}/links/{{ l.id }}/close" class="inline-form" data-confirm="Close this link? The client can no longer use it."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="linkbtn">Close the link</button></form></div>{% endif %}
</div>
{% else %}
<p class="empty-inline">A link lets the client fill in their own details, passport, address and scans from their phone, without a login. It works for 14 days, or until they press Send.</p>
{% endfor %}
</section>
{% if agreements or signed_agreements %}
<section class="card" id="agreements">
<header><h2>Agreements</h2></header>
{% for g in agreements %}
<div class="row agrow"><a href="/agreements/{{ g.id }}">{{ g.title }}</a><span class="chip {{ g.level }}">{{ g.state }}</span><span class="muted small">{{ g.note }}</span></div>
{% endfor %}
{% if signed_agreements %}
<ul class="log">
{% for s in signed_agreements %}
<li><span class="when">{{ s.at }}</span><span>{% if s.href %}<a href="{{ s.href }}" target="_blank" rel="noopener">{{ s.title }}, version {{ s.version }}</a>{% else %}{{ s.title }}, version {{ s.version }}{% endif %} signed as <b>{{ s.name }}</b>{% if s.through %} <span class="muted">({{ s.through }})</span>{% endif %}{% if s.old %} <span class="tag plain">earlier version</span>{% endif %}</span></li>
{% endfor %}
</ul>
{% endif %}
</section>
{% endif %}
<section class="card" id="recent">
<header><h2>Recent activity</h2><a class="btn sm ghost" href="/activity?person={{ p.id }}">All of it</a></header>
<ul class="log">
{% for e in recent %}
<li><span class="when">{{ e.at }}</span><span><b>{{ e.actor }}</b> {{ e.action }} {{ e.what }}{% if e.fields %} <span class="muted">({{ e.fields }})</span>{% endif %}</span></li>
{% endfor %}
</ul>
</section>
</div>
{% endblock %}