|
|
|
|
20
|
</menu>
|
20
|
</menu>
|
21
|
<program>
|
21
|
<program>
|
22
|
<![CDATA[
|
22
|
<![CDATA[
|
|
|
23
|
+ this.setWindowTitle("Typica - Batch Log");
|
23
|
var dateSelect = findChildObject(this, 'dates');
|
24
|
var dateSelect = findChildObject(this, 'dates');
|
24
|
var dateQuery = new QSqlQuery();
|
25
|
var dateQuery = new QSqlQuery();
|
25
|
dateQuery.exec("SELECT time::date FROM roasting_log WHERE time = (SELECT min(time) FROM roasting_log) OR time = (SELECT max(time) FROM roasting_log) ORDER BY time ASC");
|
26
|
dateQuery.exec("SELECT time::date FROM roasting_log WHERE time = (SELECT min(time) FROM roasting_log) OR time = (SELECT max(time) FROM roasting_log) ORDER BY time ASC");
|
|
|
|
|
163
|
output.writeAttribute("cellpadding", "3px");
|
164
|
output.writeAttribute("cellpadding", "3px");
|
164
|
output.writeStartElement("thead");
|
165
|
output.writeStartElement("thead");
|
165
|
output.writeStartElement("tr");
|
166
|
output.writeStartElement("tr");
|
|
|
167
|
+ output.writeAttribute("valign", "bottom");
|
166
|
output.writeTextElement("th", "Time");
|
168
|
output.writeTextElement("th", "Time");
|
167
|
output.writeTextElement("th", "File Numbers");
|
169
|
output.writeTextElement("th", "File Numbers");
|
168
|
output.writeTextElement("th", "Operator");
|
170
|
output.writeTextElement("th", "Operator");
|
169
|
output.writeTextElement("th", "Roasted Coffee");
|
171
|
output.writeTextElement("th", "Roasted Coffee");
|
170
|
output.writeEndElement();
|
172
|
output.writeEndElement();
|
171
|
output.writeStartElement("tr");
|
173
|
output.writeStartElement("tr");
|
|
|
174
|
+ output.writeAttribute("valign", "bottom");
|
172
|
output.writeEmptyElement("td");
|
175
|
output.writeEmptyElement("td");
|
173
|
output.writeTextElement("th", "Duration");
|
176
|
output.writeTextElement("th", "Duration");
|
174
|
output.writeTextElement("th", "Machine");
|
177
|
output.writeTextElement("th", "Machine");
|
175
|
output.writeTextElement("th", "Green Coffees");
|
178
|
output.writeTextElement("th", "Green Coffees");
|
176
|
output.writeEndElement();
|
179
|
output.writeEndElement();
|
177
|
output.writeStartElement("tr");
|
180
|
output.writeStartElement("tr");
|
|
|
181
|
+ output.writeAttribute("valign", "bottom");
|
178
|
output.writeEmptyElement("td");
|
182
|
output.writeEmptyElement("td");
|
179
|
output.writeTextElement("th", "Green Weight");
|
183
|
output.writeTextElement("th", "Green Weight");
|
180
|
output.writeTextElement("th", "Roasted Weight");
|
184
|
output.writeTextElement("th", "Roasted Weight");
|
181
|
output.writeTextElement("th", "% Weight Loss");
|
185
|
output.writeTextElement("th", "% Weight Loss");
|
182
|
output.writeEndElement();
|
186
|
output.writeEndElement();
|
183
|
output.writeStartElement("tr");
|
187
|
output.writeStartElement("tr");
|
|
|
188
|
+ output.writeAttribute("valign", "bottom");
|
184
|
output.writeEmptyElement("td");
|
189
|
output.writeEmptyElement("td");
|
185
|
output.writeStartElement("th");
|
190
|
output.writeStartElement("th");
|
186
|
output.writeAttribute("colspan", "2");
|
191
|
output.writeAttribute("colspan", "2");
|
|
|
|
|
192
|
output.writeStartElement("tbody");
|
197
|
output.writeStartElement("tbody");
|
193
|
while(query.next()) {
|
198
|
while(query.next()) {
|
194
|
output.writeStartElement("tr");
|
199
|
output.writeStartElement("tr");
|
|
|
200
|
+ output.writeAttribute("valign", "top");
|
195
|
output.writeStartElement("td");
|
201
|
output.writeStartElement("td");
|
196
|
output.writeStartElement("a");
|
202
|
output.writeStartElement("a");
|
197
|
output.writeAttribute("href", "typica://script/b/" + query.value(15));
|
203
|
output.writeAttribute("href", "typica://script/b/" + query.value(15));
|
|
|
|
|
215
|
output.writeEndElement();
|
221
|
output.writeEndElement();
|
216
|
output.writeEndElement();
|
222
|
output.writeEndElement();
|
217
|
output.writeStartElement("tr");
|
223
|
output.writeStartElement("tr");
|
|
|
224
|
+ output.writeAttribute("valign", "top");
|
218
|
output.writeEmptyElement("td");
|
225
|
output.writeEmptyElement("td");
|
219
|
output.writeTextElement("td", query.value(4));
|
226
|
output.writeTextElement("td", query.value(4));
|
220
|
output.writeTextElement("td", query.value(5));
|
227
|
output.writeTextElement("td", query.value(5));
|
221
|
output.writeTextElement("td", query.value(6));
|
228
|
output.writeTextElement("td", query.value(6));
|
222
|
output.writeEndElement();
|
229
|
output.writeEndElement();
|
223
|
output.writeStartElement("tr");
|
230
|
output.writeStartElement("tr");
|
|
|
231
|
+ output.writeAttribute("valign", "top");
|
224
|
output.writeEmptyElement("td");
|
232
|
output.writeEmptyElement("td");
|
225
|
output.writeTextElement("td", query.value(7));
|
233
|
output.writeTextElement("td", query.value(7));
|
226
|
output.writeTextElement("td", query.value(8));
|
234
|
output.writeTextElement("td", query.value(8));
|
|
|
|
|
237
|
output.writeEndElement();
|
245
|
output.writeEndElement();
|
238
|
output.writeEndElement();
|
246
|
output.writeEndElement();
|
239
|
output.writeStartElement("tr");
|
247
|
output.writeStartElement("tr");
|
|
|
248
|
+ output.writeAttribute("valign", "top");
|
240
|
output.writeEmptyElement("td");
|
249
|
output.writeEmptyElement("td");
|
241
|
output.writeStartElement("td");
|
250
|
output.writeStartElement("td");
|
242
|
output.writeAttribute("colspan", "2");
|
251
|
output.writeAttribute("colspan", "2");
|
|
|
|
|
264
|
output.writeEndElement();
|
273
|
output.writeEndElement();
|
265
|
output.writeStartElement("tfoot");
|
274
|
output.writeStartElement("tfoot");
|
266
|
output.writeStartElement("tr");
|
275
|
output.writeStartElement("tr");
|
|
|
276
|
+ output.writeAttribute("valign", "bottom");
|
267
|
output.writeTextElement("th", "Total Batches");
|
277
|
output.writeTextElement("th", "Total Batches");
|
268
|
output.writeTextElement("th", "Total Duration");
|
278
|
output.writeTextElement("th", "Total Duration");
|
269
|
output.writeTextElement("th", "Total Green Weight");
|
279
|
output.writeTextElement("th", "Total Green Weight");
|
270
|
output.writeTextElement("th", "Total Roasted Weight");
|
280
|
output.writeTextElement("th", "Total Roasted Weight");
|
271
|
output.writeEndElement();
|
281
|
output.writeEndElement();
|
272
|
output.writeStartElement("tr");
|
282
|
output.writeStartElement("tr");
|
273
|
- q = "WITH qq AS (SELECT roasting_log.time, array_to_string(files, ','), person, (SELECT name || ' (' || id || ')' FROM items WHERE id = roasted_id) AS rname, duration, (SELECT name FROM machine WHERE id = machine) AS mname, array_to_string(ARRAY(SELECT name || ' (' || id || ')' FROM items WHERE id IN (SELECT unnest(unroasted_id))), ',') AS greens, (unroasted_total_quantity/:c1)::numeric(12,2) AS uq, (roasted_quantity/:c2)::numeric(12,2) AS rq, loss, annotation, approval, spec_loss::numeric(12,2) || '±' || spec_tolerance::numeric(12,2) AS lspec, notes, loss_match, machine || '@' || roasting_log.time AS link, files FROM roasting_log, LATERAL (SELECT CASE WHEN (unroasted_total_quantity = 0) THEN NULL ELSE (((unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity)*100)::numeric(12,2) END AS loss) lc, LATERAL (WITH q AS (SELECT (SELECT min(time) - interval '10 years' FROM roasting_log) AS time, NULL::numeric AS loss, NULL::numeric AS tolerance, NULL::text AS notes) SELECT time, (loss*100)::numeric(12,2) AS spec_loss, (tolerance*100)::numeric(12,2) AS spec_tolerance, notes FROM roasting_specification WHERE item = roasted_id AND time = (SELECT max(time) FROM roasting_specification WHERE time <= roasting_log.time AND item = roasted_id) UNION (SELECT * FROM q) ORDER BY time DESC LIMIT 1) spec, LATERAL (SELECT loss >= spec_loss - spec_tolerance AND loss <= spec_loss + spec_tolerance AS loss_match) m WHERE roasting_log.time >= :sd AND roasting_log.time < :ed::date + interval '1 day'" + approvalClause + batchClause + ") SELECT count(1), sum(duration), sum(uq), sum(rq) FROM qq" + searchClause;
|
|
|
|
|
283
|
+ output.writeAttribute("valign", "top");
|
|
|
284
|
+ q = "WITH qq AS (SELECT roasting_log.time, array_to_string(files, ','), person, (SELECT name || ' (' || id || ')' FROM items WHERE id = roasted_id) AS rname, duration, (SELECT name FROM machine WHERE id = machine) AS mname, array_to_string(ARRAY(SELECT name || ' (' || id || ')' FROM items WHERE id IN (SELECT unnest(unroasted_id))), ',') AS greens, (unroasted_total_quantity/:c1)::numeric(12,2) AS uq, (roasted_quantity/:c2)::numeric(12,2) AS rq, annotation, approval, files FROM roasting_log WHERE roasting_log.time >= :sd AND roasting_log.time < :ed::date + interval '1 day'" + approvalClause + batchClause + ") SELECT count(1), sum(duration), sum(uq), sum(rq) FROM qq" + searchClause;
|
274
|
var query = new QSqlQuery();
|
285
|
var query = new QSqlQuery();
|
275
|
query.prepare(q);
|
286
|
query.prepare(q);
|
276
|
query.bind(":c1", conversion);
|
287
|
query.bind(":c1", conversion);
|