Browse Source

WIP: Manual log entry

Neal Wilson 7 years ago
parent
commit
aae2edae6d
3 changed files with 159 additions and 33 deletions
  1. 117
    0
      config/Windows/manuallogentry.xml
  2. 9
    0
      config/Windows/navigation.xml
  3. 33
    33
      config/Windows/newsamplebatch.xml

+ 117
- 0
config/Windows/manuallogentry.xml View File

@@ -0,0 +1,117 @@
1
+<window id="manualLogEntry">
2
+	<layout type="horizontal"><!-- Top horizontal layout -->
3
+		<layout type="vertical"><!-- Left vertical layout -->
4
+			<layout type="horizontal">
5
+				<label>Batch Type:</label>
6
+				<sqldrop id="batchType" />
7
+				<stretch />
8
+			</layout>
9
+			<label>Green Coffee:</label>
10
+			<layout type="stack" id="greenInfoLayout"><!-- Green information -->
11
+				<page id="sampleGreen">
12
+					<layout type="vertical">
13
+						<layout type="grid">
14
+							<row>
15
+								<column><label>Name:</label></column>
16
+								<column><line id="sampleGreenName" /></column>
17
+							</row>
18
+							<row>
19
+								<column><label>Weight:</label></column>
20
+								<column><line id="sampleGreenWeight" /></column>
21
+								<column><sqldrop id="sampleGreenUnit" /></column>
22
+							</row>
23
+							<row>
24
+								<column><label>Vendor:</label></column>
25
+								<column><line id="sampleGreenVendor" /></column>
26
+							</row>
27
+							<row>
28
+								<column><label>Arrival Date:</label></column>
29
+								<column><line id="sampleGreenArrivalDate" /></column>
30
+							</row>
31
+						</layout>
32
+						<label>Additional Details:</label>
33
+						<sqltablearray columns="2" id="attributes">
34
+							<column name="Attribute" />
35
+							<column name="Value" />
36
+						</sqltablearray>
37
+					</layout>
38
+				</page>
39
+				<page id="productionGreen">
40
+					<layout type="vertical">
41
+						<layout type="horizontal">
42
+							<label>Unit:</label>
43
+							<sqldrop id="productionGreenUnit" />
44
+							<stretch />
45
+						</layout>
46
+						<sqltablearray columns="2" id="productionGreenTable">
47
+							<column name="Coffee" delegate="sql" showdata="true" null="true" nulltext="Delete" nulldata="delete" data="0" display="1">
48
+								<![CDATA[SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name]]>
49
+							</column>
50
+							<column name="Weight" delegate="numeric" />
51
+						</sqltablearray>
52
+					</layout>
53
+				</page>
54
+			</layout><!-- End of green information -->
55
+			<label>Roasting Details:</label>
56
+			<layout type="grid">
57
+				<row>
58
+					<column><label>Item:</label></column>
59
+					<column>
60
+						<sqldrop data="0" display="1" showdata="true" id="roastedItem">
61
+							<null />
62
+							<query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
63
+						</sqldrop>
64
+					</column>
65
+				</row>
66
+				<row>
67
+					<column><label>Weight:</label></column>
68
+					<column><line id="roastedWeight" validator="numeric" /></column>
69
+				</row>
70
+				<row>
71
+					<column><label>Time:</label></column>
72
+					<column><line id="roastTime" /></column>
73
+				</row>
74
+				<row>
75
+					<column><label>Duration:</label></column>
76
+					<column><line id="roastDuration" /></column>
77
+				</row>
78
+			</layout>
79
+		</layout><!-- End of left vertical layout -->
80
+	</layout><!-- End of top horizontal layout -->
81
+	<program>
82
+	<![CDATA[
83
+		greenInfoLayout = findChildObject(this, 'greenInfoLayout');
84
+		roastedItem = findChildObject(this, 'roastedItem');
85
+		batchType = findChildObject(this, 'batchType');
86
+		batchType.addItem("Sample");
87
+		batchType.addItem("Production");
88
+		batchType['currentIndexChanged(int)'].connect(function(batchTypeIndex) {
89
+			QSettings.setValue("script/manual_batchType", batchTypeIndex);
90
+			greenInfoLayout.setCurrentIndex(batchTypeIndex);
91
+			roastedItem.enabled = (batchTypeIndex == 1);
92
+		});
93
+		batchType.setCurrentIndex(QSettings.value("script/manual_batchType", 1));
94
+		roastedItem.enabled = (batchTypeIndex == 1);
95
+		sampleGreenUnit = findChildObject(this, 'sampleGreenUnit');
96
+		sampleGreenUnit.addItem("g");
97
+		sampleGreenUnit.addItem("Kg");
98
+		sampleGreenUnit.addItem("oz");
99
+		sampleGreenUnit.addItem("lb");
100
+		sampleGreenUnit.currentIndex = (QSettings.value("script/manual_unit", sampleGreenUnit.findText("lb")));
101
+		productionGreenUnit = findChildObject(this, 'productionGreenUnit');
102
+		productionGreenUnit.addItem("g");
103
+		productionGreenUnit.addItem("Kg");
104
+		productionGreenUnit.addItem("oz");
105
+		productionGreenUnit.addItem("lb");
106
+		productionGreenUnit.currentIndex = (QSettings.value("script/manual_unit", productionGreenUnit.findText("lb")));
107
+		sampleGreenUnit['currentIndexChanged(int)'].connect(function(greenUnitIndex) {
108
+			QSettings.setValue("script/manual_unit", greenUnitIndex);
109
+			productionGreenUnit.setCurrentIndex(greenUnitIndex);
110
+		});
111
+		productionGreenUnit['currentIndexChanged(int)'].connect(function(greenUnitIndex) {
112
+			QSettings.setValue("script/manual_unit", greenUnitIndex);
113
+			sampleGreenUnit.setCurrentIndex(greenUnitIndex);
114
+		});
115
+	]]>
116
+	</program>
117
+</window>

+ 9
- 0
config/Windows/navigation.xml View File

@@ -13,6 +13,11 @@
13 13
                 <button name="Roast Coffee" id="roast" type="push" />
14 14
             </column>
15 15
         </row>
16
+		<row>
17
+			<column>
18
+				<button name="Manual Roasting Log Entry" id="manual" type="push" />
19
+			</column>
20
+		</row>
16 21
         <row>
17 22
             <column>
18 23
                 <button name="Purchase Green Coffee" id="green" type="push" />
@@ -87,6 +92,10 @@
87 92
             QSettings.setValue("database/user", "");
88 93
             QSettings.setValue("database/password", "");
89 94
         });
95
+		var manual = findChildObject(this, 'manual');
96
+		manual.clicked.connect(function() {
97
+			createWindow("manualLogEntry");
98
+		});
90 99
         var profilehistory = findChildObject(this, 'profilehistory');
91 100
         profilehistory.clicked.connect(function() {
92 101
                 createWindow("profilehistory");

+ 33
- 33
config/Windows/newsamplebatch.xml View File

@@ -132,7 +132,7 @@
132 132
 			newMenu.triggered.connect(function() {
133 133
 				createWindow("sampleRoastingBatch");
134 134
 			});
135
-                        this.endBatch = function() {};
135
+            this.endBatch = function() {};
136 136
 			var batch = this;
137 137
 			batch.submitButton = submit;
138 138
 			var name = findChildObject(this, 'name');
@@ -180,27 +180,27 @@
180 180
 			stop.clicked.connect(function() {
181 181
 				submit.setEnabled(true);
182 182
 			});
183
-                        var validateCapacity = function() {
184
-                            if(checkCapacity == "true") {
185
-                                if(convertToPounds(parseFloat(green.text), GunitBox.currentText) > poundsCapacity) {
186
-                                    return false;
187
-                                }
188
-                            }
189
-                            return true;
190
-                        }
191
-                        roastButton.clicked.connect(function() {
192
-                            var proceed = false;
193
-                            if(validateCapacity()) {
194
-                                proceed = true;
195
-                            } else {
196
-                                proceed = displayWarning(TTR("sampleRoastingBatch", "Suspicious Input"),
183
+            var validateCapacity = function() {
184
+                if(checkCapacity == "true") {
185
+                    if(convertToPounds(parseFloat(green.text), GunitBox.currentText) > poundsCapacity) {
186
+                        return false;
187
+                    }
188
+                }
189
+                return true;
190
+            }
191
+            roastButton.clicked.connect(function() {
192
+                var proceed = false;
193
+                if(validateCapacity()) {
194
+                    proceed = true;
195
+                } else {
196
+                    proceed = displayWarning(TTR("sampleRoastingBatch", "Suspicious Input"),
197 197
                                 TTR("sampleRoastingBatch", "Entered green coffee weight exceeds maximum batch size. Continue?"));
198
-                            }
199
-                            if(proceed) {
200
-                                doRoast();
201
-                            }
202
-                        });
203
-                        var doRoast = function() {
198
+                }
199
+                if(proceed) {
200
+                    doRoast();
201
+                }
202
+                });
203
+                var doRoast = function() {
204 204
 				var lc = 1;
205 205
 				currentBatchInfo = batch;
206 206
 				query = new QSqlQuery();
@@ -271,19 +271,19 @@
271 271
 			var vendor = findChildObject(this, 'vendor');
272 272
 			var attributes = findChildObject(this, 'attributes');
273 273
 			var target = findChildObject(this, 'target');
274
-                        submit.clicked.connect(function() {
275
-                            var proceed = false;
276
-                            if(validateCapacity()) {
277
-                                proceed = true;
278
-                            } else {
279
-                                proceed = displayWarning(TTR("sampleRoastingBatch", "Suspicious Input"),
274
+            submit.clicked.connect(function() {
275
+                var proceed = false;
276
+                if(validateCapacity()) {
277
+                    proceed = true;
278
+                } else {
279
+                    proceed = displayWarning(TTR("sampleRoastingBatch", "Suspicious Input"),
280 280
                                 TTR("sampleRoastingBatch", "Entered green coffee weight exceeds maximum batch size. Continue?"));
281
-                            }
282
-                            if(proceed) {
283
-                                doSubmit();
284
-                            }
285
-                        });
286
-                        var doSubmit = function() {
281
+                }
282
+                if(proceed) {
283
+                    doSubmit();
284
+                }
285
+            });
286
+            var doSubmit = function() {
287 287
 				query = new QSqlQuery();
288 288
 				query.prepare("INSERT INTO files (id, name, type, note, file) VALUES(DEFAULT, :name, 'profile', NULL, :data) RETURNING id");
289 289
 				query.bind(":name", timefield.text + " " + name.text + " " + profileName.currentText);

Loading…
Cancel
Save