|
@@ -1,35 +1,39 @@
|
1
|
1
|
<window id="roastspec">
|
2
|
|
- <layout type="vertical">
|
3
|
|
- <layout type="horizontal">
|
4
|
|
- <label>Coffee:</label>
|
5
|
|
- <sqldrop data="0" display="1" showdata="false" id="currentitems">
|
6
|
|
- <query>SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name</query>
|
7
|
|
- </sqldrop>
|
8
|
|
- </layout>
|
9
|
|
- <layout type="horizontal">
|
10
|
|
- <label>Expected % weight loss:</label>
|
11
|
|
- <line validator="numeric" id="expectedloss" />
|
12
|
|
- </layout>
|
13
|
|
- <layout type="horizontal">
|
14
|
|
- <label>Tolerance</label>
|
15
|
|
- <line validator="numeric" id="tolerance" />
|
16
|
|
- </layout>
|
17
|
|
- <label>Specification Notes:</label>
|
18
|
|
- <textarea id="notes" />
|
19
|
|
- <layout type="horizontal">
|
20
|
|
- <stretch />
|
21
|
|
- <button id="save" type="push" name="Save" />
|
|
2
|
+ <layout type="horizontal">
|
|
3
|
+ <layout type="vertical">
|
|
4
|
+ <layout type="horizontal">
|
|
5
|
+ <label>Coffee:</label>
|
|
6
|
+ <sqldrop data="0" display="1" showdata="false" id="currentitems">
|
|
7
|
+ <query>SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name</query>
|
|
8
|
+ </sqldrop>
|
|
9
|
+ </layout>
|
|
10
|
+ <layout type="horizontal">
|
|
11
|
+ <label>Expected % weight loss:</label>
|
|
12
|
+ <line validator="numeric" id="expectedloss" />
|
|
13
|
+ </layout>
|
|
14
|
+ <layout type="horizontal">
|
|
15
|
+ <label>Tolerance</label>
|
|
16
|
+ <line validator="numeric" id="tolerance" />
|
|
17
|
+ </layout>
|
|
18
|
+ <label>Specification Notes:</label>
|
|
19
|
+ <textarea id="notes" />
|
|
20
|
+ <layout type="horizontal">
|
|
21
|
+ <stretch />
|
|
22
|
+ <button id="save" type="push" name="Save" />
|
|
23
|
+ </layout>
|
22
|
24
|
</layout>
|
|
25
|
+ <svgwidget id="boxplot" />
|
23
|
26
|
</layout>
|
24
|
27
|
<program>
|
25
|
28
|
<![CDATA[
|
26
|
29
|
var window = this;
|
27
|
|
- this.windowTitle = "Typica - Edit Roasting Specification";
|
|
30
|
+ this.windowTitle = TTR("roastspec", "Typica - Edit Roasting Specification");
|
28
|
31
|
var selector = findChildObject(this, 'currentitems');
|
29
|
32
|
var expected = findChildObject(this, 'expectedloss');
|
30
|
33
|
var tolerance = findChildObject(this, 'tolerance');
|
31
|
34
|
var notes = findChildObject(this, 'notes');
|
32
|
35
|
var savebutton = findChildObject(this, 'save');
|
|
36
|
+ var boxplot = findChildObject(this, 'boxplot');
|
33
|
37
|
var updateDisplay = function() {
|
34
|
38
|
var query = new QSqlQuery();
|
35
|
39
|
query.prepare("SELECT loss, tolerance, notes FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
|
|
@@ -53,6 +57,47 @@
|
53
|
57
|
tolerance.text = "";
|
54
|
58
|
notes.plainText = "";
|
55
|
59
|
}
|
|
60
|
+ query.prepare("SELECT (unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity AS loss FROM roasting_log WHERE roasted_id = :id1 AND unroasted_id = (SELECT unroasted_id FROM roasting_log WHERE time = (SELECT max(time) FROM roasting_log WHERE roasted_id = :id2) AND roasted_id = :id3) AND approval = true ORDER BY loss ASC");
|
|
61
|
+ query.bind(":id1", selector.currentData());
|
|
62
|
+ query.bind(":id2", selector.currentData());
|
|
63
|
+ query.bind(":id3", selector.currentData());
|
|
64
|
+ query.exec();
|
|
65
|
+ var buffer = new QBuffer;
|
|
66
|
+ buffer.open(3);
|
|
67
|
+ var output = new XmlWriter(buffer);
|
|
68
|
+ output.writeStartDocument("1.0");
|
|
69
|
+ output.writeDTD('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">');
|
|
70
|
+ output.writeStartElement("svg");
|
|
71
|
+ output.writeAttribute("width", "40");
|
|
72
|
+ output.writeAttribute("height", "320");
|
|
73
|
+ output.writeStartElement("g");
|
|
74
|
+ output.writeAttribute("stroke", "black");
|
|
75
|
+ output.writeAttribute("stroke-width", "2");
|
|
76
|
+ output.writeStartElement("line");
|
|
77
|
+ output.writeAttribute("x1", "15");
|
|
78
|
+ output.writeAttribute("x2", "25");
|
|
79
|
+ output.writeAttribute("y1", "278.25");
|
|
80
|
+ output.writeAttribute("y2", "278.26");
|
|
81
|
+ output.writeTextElement("title", "17.71");
|
|
82
|
+ output.writeEndElement();
|
|
83
|
+ output.writeStartElement("line");
|
|
84
|
+ output.writeAttribute("x1", "20");
|
|
85
|
+ output.writeAttribute("x2", "20");
|
|
86
|
+ output.writeAttribute("y1", "278.25");
|
|
87
|
+ output.writeAttribute("y2", "247.5");
|
|
88
|
+ output.writeEndElement();
|
|
89
|
+ output.writeStartElement("line");
|
|
90
|
+ output.writeAttribute("x1", "10");
|
|
91
|
+ output.writeAttribute("x2", "30");
|
|
92
|
+ output.writeAttribute("y1", "247.5");
|
|
93
|
+ output.writeAttribute("y2", "247.5");
|
|
94
|
+ output.writeEndElement();
|
|
95
|
+
|
|
96
|
+ output.writeEndElement();
|
|
97
|
+ output.writeEndElement();
|
|
98
|
+ output.writeEndDocument();
|
|
99
|
+ boxplot.loadDevice(buffer);
|
|
100
|
+ buffer.close();
|
56
|
101
|
query = query.invalidate();
|
57
|
102
|
};
|
58
|
103
|
updateDisplay();
|