Browse Source

Use roast spec and approval data in daily production detail report

Neal Wilson 9 years ago
parent
commit
3d9ff0a785
1 changed files with 47 additions and 4 deletions
  1. 47
    4
      config/Reports/dailyproductiondetail.xml

+ 47
- 4
config/Reports/dailyproductiondetail.xml View File

56
 				output.writeTextElement("h1", "Daily Production Report: " + dateString);
56
 				output.writeTextElement("h1", "Daily Production Report: " + dateString);
57
 				output.writeTextElement("h2", "Batches Roasted");
57
 				output.writeTextElement("h2", "Batches Roasted");
58
 				var query = new QSqlQuery();
58
 				var query = new QSqlQuery();
59
-				var q = "SELECT time, machine, (SELECT name FROM machine WHERE id = machine), (SELECT name FROM items WHERE id = roasted_id), unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, annotation, duration, files FROM roasting_log WHERE time > '" + dateString + "' AND time < ('" + dateString + "'::date + integer '1') ORDER BY time";
59
+				var q = "SELECT time, machine, (SELECT name FROM machine WHERE id = machine), (SELECT name FROM items WHERE id = roasted_id), unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, annotation, duration, files, (SELECT loss FROM roasting_specification WHERE item = roasted_id AND time <= roasting_log.time), (SELECT tolerance FROM roasting_specification WHERE item = roasted_id AND time <= roasting_log.time), (SELECT notes FROM roasting_specification WHERE item = roasted_id AND time <= roasting_log.time), approval FROM roasting_log WHERE time > '" + dateString + "' AND time < ('" + dateString + "'::date + integer '1') ORDER BY time";
60
 				query.exec(q);
60
 				query.exec(q);
61
 				var times = new Array();
61
 				var times = new Array();
62
 				var machines = new Array();
62
 				var machines = new Array();
65
 				output.writeAttribute("cellpadding", "3px");
65
 				output.writeAttribute("cellpadding", "3px");
66
 				output.writeStartElement("thead");
66
 				output.writeStartElement("thead");
67
 				output.writeStartElement("tr");
67
 				output.writeStartElement("tr");
68
+                                output.writeAttribute("valign", "bottom");
68
 				output.writeTextElement("th", "Time");
69
 				output.writeTextElement("th", "Time");
69
 				output.writeTextElement("th", "Machine");
70
 				output.writeTextElement("th", "Machine");
70
 				output.writeTextElement("th", "Batch ID");
71
 				output.writeTextElement("th", "Batch ID");
93
 				output.writeEndElement();
94
 				output.writeEndElement();
94
 				output.writeEndElement();
95
 				output.writeEndElement();
95
 				output.writeStartElement("tbody");
96
 				output.writeStartElement("tbody");
97
+                                output.writeAttribute("valign", "top");
96
 				while(query.next())
98
 				while(query.next())
97
 				{
99
 				{
98
 					times.push(query.value(0));
100
 					times.push(query.value(0));
164
 							output.writeCDATA(query.value(8));
166
 							output.writeCDATA(query.value(8));
165
 							break;
167
 							break;
166
 					}
168
 					}
167
-					output.writeTextElement("td", query.value(3) + " (" + query.value(7) + ")");
169
+                                        output.writeStartElement("td");
170
+                                        output.writeStartElement("span");
171
+                                        if(query.value(15) == "false") {
172
+                                            output.writeAttribute("style", "color:#FF0000");
173
+                                        }
174
+                                        output.writeCharacters(query.value(3) + " (" + query.value(7) + ")");
175
+                                        output.writeEndElement();
176
+                                        output.writeEndElement();
168
 					if(Number(query.value(6)) > 0) {
177
 					if(Number(query.value(6)) > 0) {
169
 						var loss = (Number(query.value(6)) - Number(query.value(8)))/Number(query.value(6));
178
 						var loss = (Number(query.value(6)) - Number(query.value(8)))/Number(query.value(6));
179
+                                                var lossMin;
180
+                                                var lossMax;
181
+                                                var lossColor;
182
+                                                var useLoss;
183
+                                                if(query.value(12) > 0) {
184
+                                                    useLoss = true;
185
+                                                    lossMin = Number(query.value(12)) - Number(query.value(13));
186
+                                                    lossMax = Number(query.value(12)) + Number(query.value(13));
187
+                                                    if(loss >= lossMin && loss <= lossMax) {
188
+                                                        lossColor = '#00FF00';
189
+                                                    } else {
190
+                                                        lossColor = '#FF0000';
191
+                                                    }
192
+                                                } else {
193
+                                                    lossColor = '#000000';
194
+                                                    useLoss = false;
195
+                                                }
170
 						loss *= 100;
196
 						loss *= 100;
171
-						output.writeTextElement("td", loss.toFixed(2)+"%");
197
+                                                var lossSpec = Number(query.value(12)) * 100;
198
+                                                var lossTol = Number(query.value(13)) * 100;
199
+                                                output.writeStartElement("td");
200
+                                                output.writeStartElement("span");
201
+                                                output.writeAttribute("style", "color:"+lossColor);
202
+                                                if(useLoss) {
203
+                                                    output.writeAttribute("title", lossSpec.toFixed(2) + "+/-" + lossTol.toFixed(2) + "%");
204
+                                                }
205
+                                                output.writeCharacters(loss.toFixed(2) + "%");
206
+                                                output.writeEndElement();
207
+                                                output.writeEndElement();
172
 					} else {
208
 					} else {
173
 						output.writeTextElement("td", "Undefined");
209
 						output.writeTextElement("td", "Undefined");
174
 					}
210
 					}
188
 					var annotations = annotationFromRecord(files[0]);
224
 					var annotations = annotationFromRecord(files[0]);
189
 					output.writeStartElement("tr");
225
 					output.writeStartElement("tr");
190
 					output.writeStartElement("td");
226
 					output.writeStartElement("td");
191
-					output.writeAttribute("colspan", "9");
227
+					output.writeAttribute("colspan", "5");
192
 					output.writeTextElement("strong", "Profile Summary");
228
 					output.writeTextElement("strong", "Profile Summary");
193
 					var buffer2 = new QBuffer("<points>"+annotations+"</points>");
229
 					var buffer2 = new QBuffer("<points>"+annotations+"</points>");
194
 					buffer2.open(1);
230
 					buffer2.open(1);
265
 					output.writeEndElement();
301
 					output.writeEndElement();
266
 					output.writeEndElement();	
302
 					output.writeEndElement();	
267
 					output.writeEndElement();
303
 					output.writeEndElement();
304
+                                        output.writeStartElement("td");
305
+                                        output.writeAttribute("colspan", "4");
306
+                                        if(query.value(14)) {
307
+                                            output.writeTextElement("strong", "Roast Specification Notes");
308
+                                            output.writeTextElement("p", query.value(14));
309
+                                        }
310
+                                        output.writeEndElement();
268
 					output.writeEndElement();
311
 					output.writeEndElement();
269
 				}
312
 				}
270
 				output.writeEndElement();
313
 				output.writeEndElement();

Loading…
Cancel
Save