working prototype
This commit is contained in:
parent
4f2723b767
commit
1a4abe978f
21 changed files with 706 additions and 145 deletions
|
|
@ -1,39 +1,44 @@
|
|||
<!-- templates/index.html -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Print Cost Calculator</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-family: sans-serif;
|
||||
margin: 2em;
|
||||
background-color: #f9f9f9;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 3em auto;
|
||||
max-width: 900px;
|
||||
margin: auto;
|
||||
background: #fff;
|
||||
padding: 2em;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
text-align: center;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 0.7em;
|
||||
background-color: #007bff;
|
||||
|
|
@ -43,27 +48,61 @@
|
|||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
.rate-info {
|
||||
text-align: center;
|
||||
color: #555;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.color {
|
||||
background-color: #ffdede;
|
||||
}
|
||||
|
||||
.black {
|
||||
background-color: #e0e0ff;
|
||||
}
|
||||
|
||||
.totals {
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Print Cost Calculator</h1>
|
||||
|
||||
{% if error %}
|
||||
<p class="error">{{ error }}</p>
|
||||
<p class="error">{{ error }}</p>
|
||||
{% endif %}
|
||||
|
||||
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||
|
|
@ -73,9 +112,59 @@
|
|||
|
||||
<p class="rate-info">
|
||||
Rates are fixed via environment variables:<br>
|
||||
B&W: {{ rate_black if rate_black else 'RATE_PER_M2_BLACK' }} € / m²,
|
||||
B&W: {{ rate_black if rate_black else 'RATE_PER_M2_BLACK' }} € / m²,
|
||||
Color: {{ rate_color if rate_color else 'RATE_PER_M2_COLOR' }} € / m²
|
||||
</p>
|
||||
|
||||
{% if result %}
|
||||
<h2>Results for {{ result.filename }}</h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Page</th>
|
||||
<th>Width (m)</th>
|
||||
<th>Height (m)</th>
|
||||
<th>Area (m²)</th>
|
||||
<th>Ink %</th>
|
||||
<th>Type</th>
|
||||
<th>Cost (€)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for page in result.pages %}
|
||||
<tr class="{{ 'color' if page.is_color else 'black' }}">
|
||||
<td>{{ page.page }}</td>
|
||||
<td>{{ "%.3f"|format(page.width_m) }}</td>
|
||||
<td>{{ "%.3f"|format(page.height_m) }}</td>
|
||||
<td>{{ "%.4f"|format(page.area_m2) }}</td>
|
||||
<td>{{ "%.1f"|format(page.ink_pct) if page.ink_pct is not none else '-' }}</td>
|
||||
<td>{{ 'Color' if page.is_color else 'B&W' }}</td>
|
||||
<td>{{ "%.2f"|format(page.cost) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Black Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_black) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_black) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Color Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_color) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_color) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="6">Grand Total</td>
|
||||
<td>{{ "%.2f"|format(result.grand_total) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
|
@ -1,74 +1,82 @@
|
|||
<!-- templates/result.html -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Print Cost Result</title>
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2em; }
|
||||
table { border-collapse: collapse; width: 100%; margin-top: 1em; }
|
||||
th, td { border: 1px solid #ccc; padding: 0.5em; text-align: center; }
|
||||
th { background-color: #f2f2f2; }
|
||||
.color { background-color: #ffdede; }
|
||||
.black { background-color: #e0e0ff; }
|
||||
.totals { font-weight: bold; }
|
||||
.container { max-width: 900px; margin: auto; }
|
||||
h1, h2 { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Print Cost for {{ result.filename }}</h1>
|
||||
<div class="container">
|
||||
<h1>Print Cost for {{ result.filename }}</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Page</th>
|
||||
<th>Width (m)</th>
|
||||
<th>Height (m)</th>
|
||||
<th>Area (m²)</th>
|
||||
<th>Ink %</th>
|
||||
<th>Type</th>
|
||||
<th>Cost (€)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for page in result.pages %}
|
||||
<tr class="{{ 'color' if page.is_color else 'black' }}">
|
||||
<td>{{ page.page }}</td>
|
||||
<td>{{ "%.3f"|format(page.width_m) }}</td>
|
||||
<td>{{ "%.3f"|format(page.height_m) }}</td>
|
||||
<td>{{ "%.4f"|format(page.area_m2) }}</td>
|
||||
<td>{{ "%.1f"|format(page.ink_pct) if page.ink_pct is not none else '-' }}</td>
|
||||
<td>{{ 'Color' if page.is_color else 'B&W' }}</td>
|
||||
<td>{{ "%.2f"|format(page.cost) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Black Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_black) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_black) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Color Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_color) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_color) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="6">Grand Total</td>
|
||||
<td>{{ "%.2f"|format(result.grand_total) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<!-- Success / Error Banner -->
|
||||
{% if success %}
|
||||
<div class="alert success">{{ success }}</div>
|
||||
{% endif %}
|
||||
{% if error %}
|
||||
<div class="alert error">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
<p style="text-align:center; margin-top:2em;">
|
||||
<a href="/">Upload another PDF</a>
|
||||
</p>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Page</th>
|
||||
<th>Width (m)</th>
|
||||
<th>Height (m)</th>
|
||||
<th>Area (m²)</th>
|
||||
<th>Ink %</th>
|
||||
<th>Type</th>
|
||||
<th>Cost (€)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for page in result.pages %}
|
||||
<tr class="{{ 'color' if page.is_color else 'black' }}">
|
||||
<td>{{ page.page }}</td>
|
||||
<td>{{ "%.3f"|format(page.width_m) }}</td>
|
||||
<td>{{ "%.3f"|format(page.height_m) }}</td>
|
||||
<td>{{ "%.4f"|format(page.area_m2) }}</td>
|
||||
<td>{{ "%.1f"|format(page.ink_pct) if page.ink_pct is not none else '-' }}</td>
|
||||
<td>{{ 'Color' if page.is_color else 'B&W' }}</td>
|
||||
<td>{{ "%.2f"|format(page.cost) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Black Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_black) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_black) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="3">Total Color Pages</td>
|
||||
<td>{{ "%.4f"|format(result.total_area_color) }}</td>
|
||||
<td colspan="2"></td>
|
||||
<td>{{ "%.2f"|format(result.total_cost_color) }}</td>
|
||||
</tr>
|
||||
<tr class="totals">
|
||||
<td colspan="6">Grand Total</td>
|
||||
<td>{{ "%.2f"|format(result.grand_total) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<!-- Send order form -->
|
||||
<form action="/send-order" method="post">
|
||||
<input type="hidden" name="filename" value="{{ result.filename }}">
|
||||
<label for="comment"><strong>Additional Instructions:</strong></label>
|
||||
<textarea id="comment" name="comment"
|
||||
placeholder="e.g. Please print double-sided, staple in top left corner..."></textarea>
|
||||
<button type="submit">Send Order</button>
|
||||
</form>
|
||||
|
||||
<div class="link">
|
||||
<a href="/">Upload another PDF</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue