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
     <program>
14
     <program>
15
         <![CDATA[
15
         <![CDATA[
16
             var window = this;
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
             dataView = findChildObject(this, 'view');
24
             dataView = findChildObject(this, 'view');
18
             var fileID;
25
             var fileID;
19
             var target = findChildObject(this, 'target');
26
             var target = findChildObject(this, 'target');
191
                 output.writeStartElement("thead");
198
                 output.writeStartElement("thead");
192
                 output.writeStartElement("tr");
199
                 output.writeStartElement("tr");
193
                 output.writeTextElement("th", "Green Coffee");
200
                 output.writeTextElement("th", "Green Coffee");
194
-                output.writeTextElement("th", "Weight (lb)");
201
+                output.writeTextElement("th", "Weight (" + unitText + ")");
195
                 output.writeEndElement();
202
                 output.writeEndElement();
196
                 output.writeEndElement();
203
                 output.writeEndElement();
197
                 output.writeStartElement("tbody");
204
                 output.writeStartElement("tbody");
198
                 var query = new QSqlQuery();
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
                 query.bind(":time", batchTime);
207
                 query.bind(":time", batchTime);
208
+                query.bind(":c1", conversion);
209
+                query.bind(":c2", conversion);
201
                 machine = table.data(row, 1);
210
                 machine = table.data(row, 1);
202
                 query.bind(":machine", machine);
211
                 query.bind(":machine", machine);
203
                 query.exec();
212
                 query.exec();
216
                     output.writeTextElement("td", nameQuery.value(0) + " (" + items[i] + ")");
225
                     output.writeTextElement("td", nameQuery.value(0) + " (" + items[i] + ")");
217
                     output.writeStartElement("td");
226
                     output.writeStartElement("td");
218
                     output.writeAttribute("align", "center");
227
                     output.writeAttribute("align", "center");
219
-                    output.writeCharacters(quantities[i]);
228
+                    output.writeCharacters((Number(quantities[i])/conversion).toFixed(3));
220
                     output.writeEndElement();
229
                     output.writeEndElement();
221
                     output.writeEndElement();
230
                     output.writeEndElement();
222
                 }
231
                 }

Loading…
Cancel
Save