A contract's other side was one line of text. Now each other party is a row with its names in English and Thai, an ID, passport or registration number and its role (migration 0010; the old line became the first party). Parties are never deleted or rewritten: taking one off marks it removed, and both are in the journal. The conflict check (src/conflicts.rs) looks for the name or number among the clients, the other parties, the visa people and the employers. Names match regardless of case, word order, punctuation and company words in English and Thai (Co., Ltd., บริษัท ... จำกัด), or when every word of the shorter name, at least two, is in the longer one. A new party that is a client, a visa client or an employer is a conflict; a new or renamed client that was on the other side of a contract is one too; a client's name or number again is perhaps the same client. Those stop the save (409) until a lawyer ticks that they looked, with what they checked; the matches and the note go into the journal entry. /conflicts runs the check alone before a first meeting and saves nothing. Tests: 119 unit, 63 integration.
166 lines
12 KiB
HTML
166 lines
12 KiB
HTML
{% extends "base.html" %}
|
|
{% import "_fields.html" as fm %}
|
|
{% import "_agreement_text.html" as ag %}
|
|
{% import "_journal.html" as jn %}
|
|
{% import "_conflicts.html" as cf %}
|
|
{% block main %}
|
|
<div class="phead">
|
|
<div class="crumbs"><a href="/contracts">Contracts</a> <span class="sep">/</span> <a href="/clients/{{ head.client_id }}">{{ client_name }}</a></div>
|
|
<div class="pagehead">
|
|
<div>
|
|
<div class="ccode mono">{{ head.code }}</div>
|
|
<h1>{{ head.title }}</h1>
|
|
</div>
|
|
<div class="actions"><a class="btn sm" href="/contracts/{{ id }}/edit" id="edit-contract">Edit the facts</a></div>
|
|
</div>
|
|
<p class="meta">{% if artist %}<span class="tag gold">artist</span> {% endif %}{{ kind_label }}<span class="sep">·</span>for <a href="/clients/{{ head.client_id }}">{{ client_name }}</a>{% if shown.status %} <span class="chip {{ shown.status.level }}">{{ shown.status.label }}</span>{% endif %}</p>
|
|
</div>
|
|
<div class="cols">
|
|
<section class="card" id="details">
|
|
<header><h2>Facts</h2></header>
|
|
<dl class="kv">
|
|
{% for it in shown.items %}
|
|
<dt>{{ it.label }}</dt><dd class="{% if it.pre %}pre{% endif %}{% if it.mono %} mono{% endif %}">{% if it.href %}<a href="{{ it.href }}">{{ it.value }}</a>{% else %}{{ it.value }}{% endif %}</dd>
|
|
{% endfor %}
|
|
<dt>Opened</dt><dd>{{ opened }}{% if head.created_by %} by {{ head.created_by }}{% endif %}</dd>
|
|
</dl>
|
|
</section>
|
|
<section class="card" id="versions">
|
|
<header><h2>Versions</h2><span class="muted small">never changed once added</span></header>
|
|
{% for v in versions %}
|
|
<div class="item{% if reading and v.version != reading %} old{% endif %}" id="version-{{ v.version }}">
|
|
<div class="row"><b>Version {{ v.version }}</b>{% if loop.first %}<span class="tag">newest</span>{% endif %}<span class="muted small">{{ v.at }} · {{ v.by }}</span></div>
|
|
<div>{{ v.note }}</div>
|
|
<div class="vlinks small">
|
|
{% if v.has_text %}<a href="/contracts/{{ id }}?v={{ v.version }}#reading">Read the text</a> <span class="muted">({{ v.chars }} characters)</span>{% endif %}
|
|
{% if v.file %}<a href="{{ v.file }}" target="_blank" rel="noopener">{{ v.file_name }}</a> <a href="{{ v.file }}?download=1">download</a>{% endif %}
|
|
</div>
|
|
{% if v.body_sha %}<div class="muted small mono" title="SHA-256 of the text: {{ v.body_sha }}">text {{ v.body_sha[:16] }}…</div>{% endif %}
|
|
{% if v.file_sha %}<div class="muted small mono" title="SHA-256 of the file: {{ v.file_sha }}">file {{ v.file_sha[:16] }}…</div>{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<p class="empty-inline">No version yet: add the first draft below, as a text, a file or both.</p>
|
|
{% endfor %}
|
|
</section>
|
|
</div>
|
|
<section class="card" id="parties">
|
|
<header><h2>Parties</h2><span class="muted small">each one added is checked for conflicts</span></header>
|
|
<ul class="parties">
|
|
<li><div class="prow"><span><a class="strong" href="/clients/{{ head.client_id }}">{{ client_name }}</a> <span class="tag gold">our client</span></span></div></li>
|
|
{% for p in parties %}
|
|
<li id="party-{{ p.id }}"{% if p.removed %} class="old"{% endif %}>
|
|
<div class="prow">
|
|
<span><b>{{ p.name }}</b>{% if p.name_th %} <span lang="th">{{ p.name_th }}</span>{% endif %}{% if p.role %} <span class="tag">{{ p.role }}</span>{% endif %}{% if p.removed %} <span class="chip plain">removed</span>{% endif %}</span>
|
|
{% if not p.removed %}<form method="post" action="/contracts/{{ id }}/parties/{{ p.id }}/remove" class="inline-form" data-confirm="Take {{ p.name }} off this contract? It stays on record, marked removed."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Remove</button></form>{% endif %}
|
|
</div>
|
|
<div class="sub">{% if p.id_no %}<span class="mono">{{ p.id_no }}</span> · {% endif %}added {{ p.added }} by {{ p.by }}{% if p.removed %} · removed {{ p.removed }} by {{ p.removed_by }}{% endif %}</div>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% if not live_parties %}<p class="empty-inline">No other party yet: add the other side, and the check looks for it among everyone on record.</p>{% endif %}
|
|
<details class="addparty"{% if check.hits or party_errors %} open{% endif %}>
|
|
<summary class="btn sm" id="add-party-open">Add a party</summary>
|
|
<form method="post" action="/contracts/{{ id }}/parties" class="form" id="party-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
{% if check.hits %}{{ cf.block(check) }}{% endif %}
|
|
<div class="grid">
|
|
{{ fm.text("party_name", "Name", party.name, err=party_errors.party_name, req=true, cls="wide", hint="As registered, or as in the ID card or passport.") }}
|
|
{{ fm.text("party_name_th", "Name in Thai", party.name_th, err=party_errors.party_name_th, cls="wide") }}
|
|
{{ fm.text("party_id_no", "ID, passport or registration number", party.id_no, err=party_errors.party_id_no, hint="The check compares numbers too.") }}
|
|
{{ fm.text("party_role", "Role", party.role, err=party_errors.party_role, list="roles", ph="Label, venue, landlord") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="add-party">{% if check.ask %}Add the party{% else %}Check and add{% endif %}</button></div>
|
|
</form>
|
|
</details>
|
|
<datalist id="roles">{% for r in roles %}<option value="{{ r }}"></option>{% endfor %}</datalist>
|
|
</section>
|
|
{% if reading %}
|
|
<section class="card" id="reading">
|
|
<header><h2>{% if compare %}Version {{ reading }} against version {{ before }}{% else %}Version {{ reading }}{% endif %}{% if reading_note %}: {{ reading_note }}{% endif %}</h2>
|
|
{% if before %}{% if compare %}<a class="small" href="/contracts/{{ id }}?v={{ reading }}#reading">Show the text</a>{% else %}<a class="small" href="/contracts/{{ id }}?v={{ reading }}&compare=1#reading" id="compare">Compare with version {{ before }}</a>{% endif %}{% endif %}
|
|
</header>
|
|
{% if compare %}
|
|
{% if diff %}
|
|
<p class="hint">Lines taken out are struck through in red, lines added are marked in green.</p>
|
|
<div class="diff">{% for l in diff %}<div class="dl {{ l.op }}">{% if l.op == "removed" %}<del>{{ l.text or " " }}</del>{% elif l.op == "added" %}<ins>{{ l.text or " " }}</ins>{% else %}{{ l.text or " " }}{% endif %}</div>{% endfor %}</div>
|
|
{% else %}<p class="empty-inline">The texts are too long to compare here.</p>{% endif %}
|
|
{% else %}
|
|
{{ ag.text(blocks) }}
|
|
{% if reading_sha %}<p class="muted small mono hashline">SHA-256 {{ reading_sha }}</p>{% endif %}
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
<form method="post" action="/contracts/{{ id }}/versions" enctype="multipart/form-data" class="form upload" id="version-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<section class="card">
|
|
<header><h2>Add version {{ next_version }}</h2></header>
|
|
<p class="hint lead">A new draft, the other side's changes, the final text, the scan of the signed paper: each is a version. Keep the text here, attach the file (PDF or a scan), or both. A version never changes once added; its fingerprints go into the journal.</p>
|
|
<div class="grid">
|
|
{{ fm.text("note", "What this version is", draft_note, err=errors.note, req=true, cls="wide", ph="Such as: first draft, the label's changes, signed by both sides") }}
|
|
{{ fm.area("body", "Text", draft_body, err=errors.body, rows=14, fcls="wide", hint="Paragraphs separated by an empty line, # before a heading, - before a list item. It starts as the last version's text; leave it as it is to add only a file.") }}
|
|
<div class="field wide{% if errors.file %} has-err{% endif %}">
|
|
<label for="f-file">File</label>
|
|
{% if uploads %}<input id="f-file" name="file" type="file" accept="application/pdf,image/jpeg,image/png,image/webp">
|
|
<p class="hint">PDF, JPEG, PNG or WebP, up to {{ file_mb }} MB. Stored encrypted, like every document.</p>{% else %}<p class="hint">This server keeps no files: add the text only.</p>{% endif %}
|
|
{% if errors.file %}<p class="err" id="e-file">{{ errors.file }}</p>{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="add-version">Add version {{ next_version }}</button></div>
|
|
</section>
|
|
</form>
|
|
<h2 class="sechead" id="papers">Paper copies</h2>
|
|
<p class="meta">Each paper gets an id to write on it, or a label to print. Its record says where it lies; every move goes into the journal.</p>
|
|
{% if papers %}
|
|
<div class="card flush">
|
|
<div class="tblwrap">
|
|
<table class="tbl" id="paper-list">
|
|
<thead><tr><th>Id</th><th>Paper</th><th>Where it is</th><th></th></tr></thead>
|
|
<tbody>
|
|
{% for p in papers %}
|
|
<tr id="paper-{{ p.id }}"{% if p.gone %} class="old"{% endif %}>
|
|
<td><span class="pcode mono">{{ p.code }}</span></td>
|
|
<td>{{ p.what }}{% if p.version %}<div class="sub">version {{ p.version }}</div>{% endif %}</td>
|
|
<td><span class="chip {% if p.state == "filed" %}ok{% elif p.state == "out" %}warn{% else %}plain{% endif %}">{{ p.state_label }}</span> {{ p.location }}{% if p.holder %}<div class="sub">with {{ p.holder }}</div>{% endif %}<div class="sub">since {{ p.moved }}</div></td>
|
|
<td class="pacts">
|
|
<a class="btn sm ghost" href="/papers/{{ p.id }}/label" target="_blank" rel="noopener">Label</a>
|
|
<details class="move"><summary class="btn sm ghost">Move</summary>
|
|
<form method="post" action="/papers/{{ p.id }}/move" class="form mini">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<label>Where it is now<input name="location" value="{{ p.location }}" list="locations" required></label>
|
|
<label>State<select name="state">{% for s in states %}<option value="{{ s[0] }}"{% if s[0] == p.state %} selected{% endif %}>{{ s[1] }}</option>{% endfor %}</select></label>
|
|
<label>With whom<input name="holder" value="{{ p.holder }}" placeholder="While it is out, or whom it went to"></label>
|
|
<label>Note<input name="note" placeholder="Such as: for the signing at the label"></label>
|
|
<button type="submit" class="btn sm pri">Save the move</button>
|
|
</form>
|
|
</details>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
<form method="post" action="/contracts/{{ id }}/papers" class="form" id="paper-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<section class="card">
|
|
<header><h2>Register a paper copy</h2></header>
|
|
<div class="grid">
|
|
{{ fm.text("what", "What it is", "", req=true, list="whats", ph="Signed original") }}
|
|
<div class="field">
|
|
<label for="f-version">Version</label>
|
|
<select id="f-version" name="version"><option value="">Not known</option>{% for v in versions %}<option value="{{ v.version }}"{% if loop.first %} selected{% endif %}>Version {{ v.version }}: {{ v.note }}</option>{% endfor %}</select>
|
|
</div>
|
|
{{ fm.text("location", "Where it is filed", "", req=true, list="locations", cls="wide", ph="Office, cabinet A, drawer 2, folder of the client") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn" id="add-paper">Register and give it an id</button></div>
|
|
</section>
|
|
</form>
|
|
<datalist id="whats">{% for w in whats %}<option value="{{ w }}"></option>{% endfor %}</datalist>
|
|
<datalist id="locations">{% for l in locations %}<option value="{{ l }}"></option>{% endfor %}</datalist>
|
|
<section class="card" id="contract-journal">
|
|
<header><h2>Journal of this contract</h2><a class="small" href="/journal">The whole journal, checked</a></header>
|
|
{% if entries %}{{ jn.list(entries) }}{% else %}<p class="empty-inline">Nothing yet.</p>{% endif %}
|
|
</section>
|
|
{% endblock %}
|