Browse Source

Batch details inherit unit from batch log

Neal Wilson 9 years ago
parent
commit
81e82b2b82
1 changed files with 12 additions and 3 deletions
  1. 12
    3
      config/Windows/batchdetailsnew.xml

+ 12
- 3
config/Windows/batchdetailsnew.xml View File

@@ -14,6 +14,13 @@
14 14
     <program>
15 15
         <![CDATA[
16 16
             var window = this;
17
+            var unit = QSettings.value("script/history_unit", 1);
18
+            var conversion = 1;
19
+            if(unit == 0)
20
+            {
21
+                conversion = 2.2;
22
+            }
23
+            var unitText = (unit == 0 ? "Kg" : "Lb");
17 24
             dataView = findChildObject(this, 'view');
18 25
             var fileID;
19 26
             var target = findChildObject(this, 'target');
@@ -191,13 +198,15 @@
191 198
                 output.writeStartElement("thead");
192 199
                 output.writeStartElement("tr");
193 200
                 output.writeTextElement("th", "Green Coffee");
194
-                output.writeTextElement("th", "Weight (lb)");
201
+                output.writeTextElement("th", "Weight (" + unitText + ")");
195 202
                 output.writeEndElement();
196 203
                 output.writeEndElement();
197 204
                 output.writeStartElement("tbody");
198 205
                 var query = new QSqlQuery();
199
-                query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation, unroasted_total_quantity, roasted_quantity FROM roasting_log WHERE time = :time AND machine = :machine");
206
+                query.prepare("SELECT unroasted_id, unroasted_quantity, approval, files, annotation, (unroasted_total_quantity/:c1)::numeric(12,3), (roasted_quantity/:c2)::numeric(12,3) FROM roasting_log WHERE time = :time AND machine = :machine");
200 207
                 query.bind(":time", batchTime);
208
+                query.bind(":c1", conversion);
209
+                query.bind(":c2", conversion);
201 210
                 machine = table.data(row, 1);
202 211
                 query.bind(":machine", machine);
203 212
                 query.exec();
@@ -216,7 +225,7 @@
216 225
                     output.writeTextElement("td", nameQuery.value(0) + " (" + items[i] + ")");
217 226
                     output.writeStartElement("td");
218 227
                     output.writeAttribute("align", "center");
219
-                    output.writeCharacters(quantities[i]);
228
+                    output.writeCharacters((Number(quantities[i])/conversion).toFixed(3));
220 229
                     output.writeEndElement();
221 230
                     output.writeEndElement();
222 231
                 }

Loading…
Cancel
Save