Browse Source

Add NOTIFY support for production reports

Neal Wilson 6 years ago
parent
commit
578943a249

+ 4
- 0
config/Reports/auco.xml View File

@@ -213,6 +213,10 @@
213 213
                 QSettings.setValue("auco_sort", sortBox.currentIndex);
214 214
                 refresh();
215 215
             });
216
+            var notifier = Application.subscribe("transactionschange");
217
+            notifier.notify.connect(function() {
218
+                refresh();
219
+            });
216 220
             report.scriptLinkClicked.connect(function(url) {
217 221
                 if(url[0] == 'i') {
218 222
                     url = url.slice(1, url.length);

+ 4
- 0
config/Reports/chart.xml View File

@@ -558,6 +558,10 @@
558 558
             avgField.editingFinished.connect(function() {
559 559
                 refresh();
560 560
             });
561
+            var notifier = Application.subscribe("roastinglogchange");
562
+            notifier.notify.connect(function() {
563
+                refresh();
564
+            });
561 565
         ]]>
562 566
     </program>
563 567
 </window>

+ 8
- 0
config/Reports/cogr.xml View File

@@ -168,6 +168,14 @@
168 168
                 buffer.close();
169 169
             };
170 170
             refresh();
171
+            var notifier = Application.subscribe("roastinglogchange");
172
+            notifier.notify.connect(function() {
173
+                refresh();
174
+            });
175
+            var notifier2 = Application.subscribe("purchasechange");
176
+            notifier2.notify.connect(function() {
177
+                refresh();
178
+            });
171 179
         ]]>
172 180
     </program>
173 181
 </window>

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

@@ -469,6 +469,10 @@
469 469
 			dateField.dateChanged.connect(function() {
470 470
 				refresh();
471 471
 			});
472
+            var notifier = Application.subscribe("roastinglogchange");
473
+            notifier.notify.connect(function() {
474
+                refresh();
475
+            });
472 476
 			
473 477
 			view.scriptLinkClicked.connect(function(url) {
474 478
 				var arg = url.slice(1, url.length);

+ 5
- 1
config/Reports/greenforroasted.xml View File

@@ -114,6 +114,10 @@
114 114
                 buffer.close();
115 115
             }
116 116
             refresh();
117
+            var notifier = Application.subscribe("roastinglogchange");
118
+            notifier.notify.connect(function() {
119
+                refresh();
120
+            });
117 121
         ]]>
118 122
     </program>
119
-</window>
123
+</window>

+ 216
- 209
config/Reports/lossplots.xml View File

@@ -14,229 +14,236 @@ var printMenu = findChildObject(this, 'print');
14 14
 printMenu.triggered.connect(function() {
15 15
     report.print();
16 16
 });
17
-var query = new QSqlQuery;
18
-query.exec("WITH a AS (SELECT roasted_id, max(time) AS last_batch FROM roasting_log WHERE roasted_id IN (SELECT item FROM current_items) GROUP BY roasted_id), b AS (SELECT roasted_id, last_batch, (SELECT unroasted_id FROM roasting_log WHERE roasted_id = a.roasted_id AND time = last_batch) FROM a), c AS (SELECT roasting_log.roasted_id, ((unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity) AS loss FROM roasting_log, b WHERE roasting_log.roasted_id = b.roasted_id AND roasting_log.unroasted_id = b.unroasted_id AND unroasted_total_quantity > 0 AND approval = true) SELECT roasted_id, (SELECT name FROM items WHERE id = roasted_id) AS name, count(1), min(loss), percentile_cont(0.25) WITHIN GROUP (ORDER BY loss) AS lower_quart, percentile_cont(0.5) WITHIN GROUP (ORDER BY loss) AS median, percentile_cont(0.75) WITHIN GROUP (ORDER BY loss) AS upper_quart, max(loss), avg(loss) FROM c GROUP BY roasted_id ORDER BY name ASC");
19
-var items = new Array;
20
-while(query.next()) {
21
-    var item = new Object;
22
-    item.roasted_id = query.value(0);
23
-    item.name = query.value(1);
24
-    item.mean = query.value(8);
25
-    item.min = query.value(3);
26
-    item.max = query.value(7);
27
-    item.plots = new Array;
28
-    var plot = new Object;
29
-    plot.count = query.value(2);
30
-    plot.min = item.min;
31
-    plot.max = item.max;
32
-    plot.lower_quart = query.value(4);
33
-    plot.median = query.value(5);
34
-    plot.upper_quart = query.value(6);
35
-    plot.name = "All";
36
-    item.plots.push(plot);
37
-    items.push(item);
38
-}
39
-query.exec("WITH a AS (SELECT roasted_id, max(time) AS last_batch FROM roasting_log WHERE roasted_id IN (SELECT item FROM current_items) GROUP BY roasted_id), b AS (SELECT roasted_id, last_batch, (SELECT unroasted_id FROM roasting_log WHERE roasted_id = a.roasted_id AND time = last_batch) FROM a), c AS (SELECT roasting_log.roasted_id, ((unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity) AS loss, person FROM roasting_log, b WHERE roasting_log.roasted_id = b.roasted_id AND roasting_log.unroasted_id = b.unroasted_id AND unroasted_total_quantity > 0 AND approval = true) SELECT roasted_id, person, count(1), min(loss), percentile_cont(0.25) WITHIN GROUP (ORDER BY loss) AS lower_quart, percentile_cont(0.5) WITHIN GROUP (ORDER BY loss) AS median, percentile_cont(0.75) WITHIN GROUP (ORDER BY loss) AS upper_quart, max(loss) FROM c GROUP BY roasted_id, person");
40
-while(query.next()) {
41
-    var plot = new Object;
42
-    plot.count = query.value(2);
43
-    plot.min = query.value(3);
44
-    plot.max = query.value(7);
45
-    plot.lower_quart = query.value(4);
46
-    plot.median = query.value(5);
47
-    plot.upper_quart = query.value(6);
48
-    plot.name = query.value(1);
49
-    for(var i = 0; i < items.length; i++) {
50
-        if(items[i].roasted_id == query.value(0)) {
51
-            items[i].plots.push(plot);
52
-            break;
17
+var refresh = function() {
18
+    var query = new QSqlQuery;
19
+    query.exec("WITH a AS (SELECT roasted_id, max(time) AS last_batch FROM roasting_log WHERE roasted_id IN (SELECT item FROM current_items) GROUP BY roasted_id), b AS (SELECT roasted_id, last_batch, (SELECT unroasted_id FROM roasting_log WHERE roasted_id = a.roasted_id AND time = last_batch) FROM a), c AS (SELECT roasting_log.roasted_id, ((unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity) AS loss FROM roasting_log, b WHERE roasting_log.roasted_id = b.roasted_id AND roasting_log.unroasted_id = b.unroasted_id AND unroasted_total_quantity > 0 AND approval = true) SELECT roasted_id, (SELECT name FROM items WHERE id = roasted_id) AS name, count(1), min(loss), percentile_cont(0.25) WITHIN GROUP (ORDER BY loss) AS lower_quart, percentile_cont(0.5) WITHIN GROUP (ORDER BY loss) AS median, percentile_cont(0.75) WITHIN GROUP (ORDER BY loss) AS upper_quart, max(loss), avg(loss) FROM c GROUP BY roasted_id ORDER BY name ASC");
20
+    var items = new Array;
21
+    while(query.next()) {
22
+        var item = new Object;
23
+        item.roasted_id = query.value(0);
24
+        item.name = query.value(1);
25
+        item.mean = query.value(8);
26
+        item.min = query.value(3);
27
+        item.max = query.value(7);
28
+        item.plots = new Array;
29
+        var plot = new Object;
30
+        plot.count = query.value(2);
31
+        plot.min = item.min;
32
+        plot.max = item.max;
33
+        plot.lower_quart = query.value(4);
34
+        plot.median = query.value(5);
35
+        plot.upper_quart = query.value(6);
36
+        plot.name = "All";
37
+        item.plots.push(plot);
38
+        items.push(item);
39
+    }
40
+    query.exec("WITH a AS (SELECT roasted_id, max(time) AS last_batch FROM roasting_log WHERE roasted_id IN (SELECT item FROM current_items) GROUP BY roasted_id), b AS (SELECT roasted_id, last_batch, (SELECT unroasted_id FROM roasting_log WHERE roasted_id = a.roasted_id AND time = last_batch) FROM a), c AS (SELECT roasting_log.roasted_id, ((unroasted_total_quantity - roasted_quantity)/unroasted_total_quantity) AS loss, person FROM roasting_log, b WHERE roasting_log.roasted_id = b.roasted_id AND roasting_log.unroasted_id = b.unroasted_id AND unroasted_total_quantity > 0 AND approval = true) SELECT roasted_id, person, count(1), min(loss), percentile_cont(0.25) WITHIN GROUP (ORDER BY loss) AS lower_quart, percentile_cont(0.5) WITHIN GROUP (ORDER BY loss) AS median, percentile_cont(0.75) WITHIN GROUP (ORDER BY loss) AS upper_quart, max(loss) FROM c GROUP BY roasted_id, person");
41
+    while(query.next()) {
42
+        var plot = new Object;
43
+        plot.count = query.value(2);
44
+        plot.min = query.value(3);
45
+        plot.max = query.value(7);
46
+        plot.lower_quart = query.value(4);
47
+        plot.median = query.value(5);
48
+        plot.upper_quart = query.value(6);
49
+        plot.name = query.value(1);
50
+        for(var i = 0; i < items.length; i++) {
51
+            if(items[i].roasted_id == query.value(0)) {
52
+                items[i].plots.push(plot);
53
+                break;
54
+            }
53 55
         }
54 56
     }
55
-}
56
-query = query.invalidate();
57
-var buffer = new QBuffer;
58
-buffer.open(3);
59
-var output = new XmlWriter(buffer);
60
-output.writeStartDocument("1.0");
61
-output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
62
-output.writeStartElement("html");
63
-output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
64
-output.writeStartElement("head");
65
-output.writeTextElement("style", ".box {font: 10px sans-serif;} .whisker {font: 10px sans-serif;} .axis {font: 12px sans-serif;} .axis path {fill: none; stroke: #000; shape-rendering: crispEdges;} .axis line {fill: none; stroke: #000; shape-rendering: crispEdges;} .x.axis path {fill: none; stroke: #000; shape-rendering: crispEdges;}");
66
-output.writeEndElement(); //head
67
-output.writeStartElement("body");
68
-var cdt = new Date(Date.now());
69
-output.writeTextElement("p", cdt.toLocaleDateString(TTR("reports", "en-US")) + " " + cdt.toLocaleTimeString(TTR("reports", "en-US")));
70
-function position(value, min, max) {
71
-    return 300 - (((Number(value)-Number(min))/(Number(max)-Number(min)))*300);
72
-}
73
-for(var i = 0; i < items.length; i++) {
74
-    output.writeStartElement("svg");
75
-    output.writeAttribute("xmlns", "http://www.w3.org/2000/svg");
76
-    output.writeAttribute("height", "420");
77
-    output.writeAttribute("width", 84 + (items[i].plots.length * 179));
78
-    output.writeStartElement("g"); //plots
79
-    output.writeAttribute("transform", "translate(50,30)");
80
-    var plotMin = items[i].min;
81
-    var plotMax = items[i].max;
82
-    for(var j = 0; j < items[i].plots.length; j++) {
83
-        output.writeStartElement("g"); //plot
84
-        output.writeAttribute("transform", "translate(" + (55 + (179 * j)).toString() + ",30)");
85
-        output.writeStartElement("line"); //center line
57
+    query = query.invalidate();
58
+    var buffer = new QBuffer;
59
+    buffer.open(3);
60
+    var output = new XmlWriter(buffer);
61
+    output.writeStartDocument("1.0");
62
+    output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
63
+    output.writeStartElement("html");
64
+    output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
65
+    output.writeStartElement("head");
66
+    output.writeTextElement("style", ".box {font: 10px sans-serif;} .whisker {font: 10px sans-serif;} .axis {font: 12px sans-serif;} .axis path {fill: none; stroke: #000; shape-rendering: crispEdges;} .axis line {fill: none; stroke: #000; shape-rendering: crispEdges;} .x.axis path {fill: none; stroke: #000; shape-rendering: crispEdges;}");
67
+    output.writeEndElement(); //head
68
+    output.writeStartElement("body");
69
+    var cdt = new Date(Date.now());
70
+    output.writeTextElement("p", cdt.toLocaleDateString(TTR("reports", "en-US")) + " " + cdt.toLocaleTimeString(TTR("reports", "en-US")));
71
+    function position(value, min, max) {
72
+        return 300 - (((Number(value)-Number(min))/(Number(max)-Number(min)))*300);
73
+    }
74
+    for(var i = 0; i < items.length; i++) {
75
+        output.writeStartElement("svg");
76
+        output.writeAttribute("xmlns", "http://www.w3.org/2000/svg");
77
+        output.writeAttribute("height", "420");
78
+        output.writeAttribute("width", 84 + (items[i].plots.length * 179));
79
+        output.writeStartElement("g"); //plots
80
+        output.writeAttribute("transform", "translate(50,30)");
81
+        var plotMin = items[i].min;
82
+        var plotMax = items[i].max;
83
+        for(var j = 0; j < items[i].plots.length; j++) {
84
+            output.writeStartElement("g"); //plot
85
+            output.writeAttribute("transform", "translate(" + (55 + (179 * j)).toString() + ",30)");
86
+            output.writeStartElement("line"); //center line
87
+            output.writeAttribute("class", "center");
88
+            output.writeAttribute("style", "fill: #000; stroke: #000; stroke-width: 1px;");
89
+            output.writeAttribute("x1", "27");
90
+            output.writeAttribute("x2", "27");
91
+            output.writeAttribute("y1", position(items[i].plots[j].min, plotMin, plotMax));
92
+            output.writeAttribute("y2", position(items[i].plots[j].max, plotMin, plotMax));
93
+            output.writeEndElement(); //line
94
+            output.writeStartElement("rect"); //upper and lower quartiles box
95
+            output.writeAttribute("class", "box");
96
+            output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
97
+            output.writeAttribute("x", "0");
98
+            output.writeAttribute("width", "54");
99
+            output.writeAttribute("y", position(items[i].plots[j].upper_quart, plotMin, plotMax));
100
+            output.writeAttribute("height", position(items[i].plots[j].lower_quart, plotMin, plotMax) - position(items[i].plots[j].upper_quart, plotMin, plotMax));
101
+            output.writeEndElement(); //rect
102
+            output.writeStartElement("line"); //median line
103
+            output.writeAttribute("class", "median");
104
+            output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
105
+            output.writeAttribute("x1", "0");
106
+            output.writeAttribute("x2", "54");
107
+            output.writeAttribute("y1", position(items[i].plots[j].median, plotMin, plotMax));
108
+            output.writeAttribute("y2", position(items[i].plots[j].median, plotMin, plotMax));
109
+            output.writeEndElement(); //line
110
+            output.writeStartElement("line"); //minimum whisker
111
+            output.writeAttribute("class", "whisker");
112
+            output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
113
+            output.writeAttribute("x1", "0");
114
+            output.writeAttribute("x2", "54");
115
+            output.writeAttribute("y1", position(items[i].plots[j].min, plotMin, plotMax));
116
+            output.writeAttribute("y2", position(items[i].plots[j].min, plotMin, plotMax));
117
+            output.writeEndElement(); //line
118
+            output.writeStartElement("line"); //maximum whisker
119
+            output.writeAttribute("class", "whisker");
120
+            output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
121
+            output.writeAttribute("x1", "0");
122
+            output.writeAttribute("x2", "54");
123
+            output.writeAttribute("y1", position(items[i].plots[j].max, plotMin, plotMax));
124
+            output.writeAttribute("y2", position(items[i].plots[j].max, plotMin, plotMax));
125
+            output.writeEndElement(); //line
126
+            output.writeStartElement("text"); //upper quartile label
127
+            output.writeAttribute("class", "box");
128
+            output.writeAttribute("dy", ".3em");
129
+            output.writeAttribute("dx", "-6");
130
+            output.writeAttribute("x", "0");
131
+            output.writeAttribute("y", position(items[i].plots[j].upper_quart, plotMin, plotMax));
132
+            output.writeAttribute("text-anchor", "end");
133
+            output.writeCharacters(Number(items[i].plots[j].upper_quart * 100).toFixed(2) + "%");
134
+            output.writeEndElement(); //text
135
+            output.writeStartElement("text"); //lower quartile label
136
+            output.writeAttribute("class", "box");
137
+            output.writeAttribute("dy", ".3em");
138
+            output.writeAttribute("dx", "-6");
139
+            output.writeAttribute("x", "0");
140
+            output.writeAttribute("y", position(items[i].plots[j].lower_quart, plotMin, plotMax));
141
+            output.writeAttribute("text-anchor", "end");
142
+            output.writeCharacters(Number(items[i].plots[j].lower_quart * 100).toFixed(2) + "%");
143
+            output.writeEndElement(); //text
144
+            output.writeStartElement("text"); //median label
145
+            output.writeAttribute("class", "box");
146
+            output.writeAttribute("dy", ".3em");
147
+            output.writeAttribute("dx", "6");
148
+            output.writeAttribute("x", "54");
149
+            output.writeAttribute("y", position(items[i].plots[j].median, plotMin, plotMax));
150
+            output.writeAttribute("text-anchor", "start");
151
+            output.writeCharacters(Number(items[i].plots[j].median * 100).toFixed(2) + "%");
152
+            output.writeEndElement(); //text
153
+            output.writeStartElement("text"); //minimum label
154
+            output.writeAttribute("class", "whisker");
155
+            output.writeAttribute("dy", ".3em");
156
+            output.writeAttribute("dx", "6");
157
+            output.writeAttribute("x", "54");
158
+            output.writeAttribute("y", position(items[i].plots[j].min, plotMin, plotMax));
159
+            output.writeAttribute("text-anchor", "start");
160
+            output.writeCharacters(Number(items[i].plots[j].min * 100).toFixed(2) + "%");
161
+            output.writeEndElement(); //text
162
+            output.writeStartElement("text"); //maximum label
163
+            output.writeAttribute("class", "whisker");
164
+            output.writeAttribute("dy", ".3em");
165
+            output.writeAttribute("dx", "6");
166
+            output.writeAttribute("x", "54");
167
+            output.writeAttribute("y", position(items[i].plots[j].max, plotMin, plotMax));
168
+            output.writeAttribute("text-anchor", "start");
169
+            output.writeCharacters(Number(items[i].plots[j].max * 100).toFixed(2) + "%");
170
+            output.writeEndElement(); //text
171
+            output.writeEndElement(); //g
172
+        }
173
+        output.writeStartElement("g"); //mean line and label
174
+        output.writeAttribute("transform", "translate(0, 30)");
175
+        output.writeStartElement("line");
86 176
         output.writeAttribute("class", "center");
87
-        output.writeAttribute("style", "fill: #000; stroke: #000; stroke-width: 1px;");
88
-        output.writeAttribute("x1", "27");
89
-        output.writeAttribute("x2", "27");
90
-        output.writeAttribute("y1", position(items[i].plots[j].min, plotMin, plotMax));
91
-        output.writeAttribute("y2", position(items[i].plots[j].max, plotMin, plotMax));
92
-        output.writeEndElement(); //line
93
-        output.writeStartElement("rect"); //upper and lower quartiles box
94
-        output.writeAttribute("class", "box");
95
-        output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
96
-        output.writeAttribute("x", "0");
97
-        output.writeAttribute("width", "54");
98
-        output.writeAttribute("y", position(items[i].plots[j].upper_quart, plotMin, plotMax));
99
-        output.writeAttribute("height", position(items[i].plots[j].lower_quart, plotMin, plotMax) - position(items[i].plots[j].upper_quart, plotMin, plotMax));
100
-        output.writeEndElement(); //rect
101
-        output.writeStartElement("line"); //median line
102
-        output.writeAttribute("class", "median");
103
-        output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
177
+        output.writeAttribute("style", "stroke: #000; stroke-width: 1px;");
104 178
         output.writeAttribute("x1", "0");
105
-        output.writeAttribute("x2", "54");
106
-        output.writeAttribute("y1", position(items[i].plots[j].median, plotMin, plotMax));
107
-        output.writeAttribute("y2", position(items[i].plots[j].median, plotMin, plotMax));
179
+        output.writeAttribute("x2", (items[i].plots.length * 179) - 16);
180
+        output.writeAttribute("y1", position(items[i].mean, plotMin, plotMax));
181
+        output.writeAttribute("y2", position(items[i].mean, plotMin, plotMax));
108 182
         output.writeEndElement(); //line
109
-        output.writeStartElement("line"); //minimum whisker
110
-        output.writeAttribute("class", "whisker");
111
-        output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
112
-        output.writeAttribute("x1", "0");
113
-        output.writeAttribute("x2", "54");
114
-        output.writeAttribute("y1", position(items[i].plots[j].min, plotMin, plotMax));
115
-        output.writeAttribute("y2", position(items[i].plots[j].min, plotMin, plotMax));
116
-        output.writeEndElement(); //line
117
-        output.writeStartElement("line"); //maximum whisker
118
-        output.writeAttribute("class", "whisker");
119
-        output.writeAttribute("style", "fill: #12DD11; stroke: #000; stroke-width: 1px;");
120
-        output.writeAttribute("x1", "0");
121
-        output.writeAttribute("x2", "54");
122
-        output.writeAttribute("y1", position(items[i].plots[j].max, plotMin, plotMax));
123
-        output.writeAttribute("y2", position(items[i].plots[j].max, plotMin, plotMax));
124
-        output.writeEndElement(); //line
125
-        output.writeStartElement("text"); //upper quartile label
183
+        output.writeStartElement("text");
126 184
         output.writeAttribute("class", "box");
127 185
         output.writeAttribute("dy", ".3em");
128 186
         output.writeAttribute("dx", "-6");
129 187
         output.writeAttribute("x", "0");
130
-        output.writeAttribute("y", position(items[i].plots[j].upper_quart, plotMin, plotMax));
188
+        output.writeAttribute("y", position(items[i].mean, plotMin, plotMax));
131 189
         output.writeAttribute("text-anchor", "end");
132
-        output.writeCharacters(Number(items[i].plots[j].upper_quart * 100).toFixed(2) + "%");
133
-        output.writeEndElement(); //text
134
-        output.writeStartElement("text"); //lower quartile label
135
-        output.writeAttribute("class", "box");
136
-        output.writeAttribute("dy", ".3em");
137
-        output.writeAttribute("dx", "-6");
138
-        output.writeAttribute("x", "0");
139
-        output.writeAttribute("y", position(items[i].plots[j].lower_quart, plotMin, plotMax));
140
-        output.writeAttribute("text-anchor", "end");
141
-        output.writeCharacters(Number(items[i].plots[j].lower_quart * 100).toFixed(2) + "%");
142
-        output.writeEndElement(); //text
143
-        output.writeStartElement("text"); //median label
144
-        output.writeAttribute("class", "box");
145
-        output.writeAttribute("dy", ".3em");
146
-        output.writeAttribute("dx", "6");
147
-        output.writeAttribute("x", "54");
148
-        output.writeAttribute("y", position(items[i].plots[j].median, plotMin, plotMax));
149
-        output.writeAttribute("text-anchor", "start");
150
-        output.writeCharacters(Number(items[i].plots[j].median * 100).toFixed(2) + "%");
151
-        output.writeEndElement(); //text
152
-        output.writeStartElement("text"); //minimum label
153
-        output.writeAttribute("class", "whisker");
154
-        output.writeAttribute("dy", ".3em");
155
-        output.writeAttribute("dx", "6");
156
-        output.writeAttribute("x", "54");
157
-        output.writeAttribute("y", position(items[i].plots[j].min, plotMin, plotMax));
158
-        output.writeAttribute("text-anchor", "start");
159
-        output.writeCharacters(Number(items[i].plots[j].min * 100).toFixed(2) + "%");
160
-        output.writeEndElement(); //text
161
-        output.writeStartElement("text"); //maximum label
162
-        output.writeAttribute("class", "whisker");
163
-        output.writeAttribute("dy", ".3em");
164
-        output.writeAttribute("dx", "6");
165
-        output.writeAttribute("x", "54");
166
-        output.writeAttribute("y", position(items[i].plots[j].max, plotMin, plotMax));
167
-        output.writeAttribute("text-anchor", "start");
168
-        output.writeCharacters(Number(items[i].plots[j].max * 100).toFixed(2) + "%");
190
+        output.writeCharacters(Number(items[i].mean * 100).toFixed(2) + "%");
169 191
         output.writeEndElement(); //text
170 192
         output.writeEndElement(); //g
171
-    }
172
-    output.writeStartElement("g"); //mean line and label
173
-    output.writeAttribute("transform", "translate(0, 30)");
174
-    output.writeStartElement("line");
175
-    output.writeAttribute("class", "center");
176
-    output.writeAttribute("style", "stroke: #000; stroke-width: 1px;");
177
-    output.writeAttribute("x1", "0");
178
-    output.writeAttribute("x2", (items[i].plots.length * 179) - 16);
179
-    output.writeAttribute("y1", position(items[i].mean, plotMin, plotMax));
180
-    output.writeAttribute("y2", position(items[i].mean, plotMin, plotMax));
181
-    output.writeEndElement(); //line
182
-    output.writeStartElement("text");
183
-    output.writeAttribute("class", "box");
184
-    output.writeAttribute("dy", ".3em");
185
-    output.writeAttribute("dx", "-6");
186
-    output.writeAttribute("x", "0");
187
-    output.writeAttribute("y", position(items[i].mean, plotMin, plotMax));
188
-    output.writeAttribute("text-anchor", "end");
189
-    output.writeCharacters(Number(items[i].mean * 100).toFixed(2) + "%");
190
-    output.writeEndElement(); //text
191
-    output.writeEndElement(); //g
192
-    output.writeStartElement("g") //x axis
193
-    output.writeAttribute("class", "x axis");
194
-    output.writeAttribute("transform", "translate(0,340)");
195
-    for(var j = 0; j < items[i].plots.length; j++) {
196
-        output.writeStartElement("g"); //name and population size
197
-        output.writeAttribute("class", "tick");
198
-        output.writeAttribute("transform", "translate(" + (82 + (j * 179)) + ",0)");
199
-        output.writeStartElement("line"); //tick
200
-        output.writeAttribute("y2", "6");
201
-        output.writeAttribute("x2", "0");
202
-        output.writeEndElement(); //line
203
-        output.writeStartElement("text"); //label
204
-        output.writeAttribute("style", "text-anchor: middle");
205
-        output.writeAttribute("y", "9");
206
-        output.writeAttribute("x", "0");
207
-        output.writeStartElement("tspan");
208
-        output.writeAttribute("x", "0");
209
-        output.writeAttribute("dy", ".71em");
210
-        output.writeCharacters(items[i].plots[j].name);
211
-        output.writeEndElement(); //tspan
212
-        output.writeStartElement("tspan");
213
-        output.writeAttribute("x", "0");
214
-        output.writeAttribute("dy", "1.42em");
215
-        output.writeCharacters("(n=" + items[i].plots[j].count + ")");
216
-        output.writeEndElement(); //tspan
193
+        output.writeStartElement("g") //x axis
194
+        output.writeAttribute("class", "x axis");
195
+        output.writeAttribute("transform", "translate(0,340)");
196
+        for(var j = 0; j < items[i].plots.length; j++) {
197
+            output.writeStartElement("g"); //name and population size
198
+            output.writeAttribute("class", "tick");
199
+            output.writeAttribute("transform", "translate(" + (82 + (j * 179)) + ",0)");
200
+            output.writeStartElement("line"); //tick
201
+            output.writeAttribute("y2", "6");
202
+            output.writeAttribute("x2", "0");
203
+            output.writeEndElement(); //line
204
+            output.writeStartElement("text"); //label
205
+            output.writeAttribute("style", "text-anchor: middle");
206
+            output.writeAttribute("y", "9");
207
+            output.writeAttribute("x", "0");
208
+            output.writeStartElement("tspan");
209
+            output.writeAttribute("x", "0");
210
+            output.writeAttribute("dy", ".71em");
211
+            output.writeCharacters(items[i].plots[j].name);
212
+            output.writeEndElement(); //tspan
213
+            output.writeStartElement("tspan");
214
+            output.writeAttribute("x", "0");
215
+            output.writeAttribute("dy", "1.42em");
216
+            output.writeCharacters("(n=" + items[i].plots[j].count + ")");
217
+            output.writeEndElement(); //tspan
218
+            output.writeEndElement(); //text
219
+            output.writeEndElement(); //g
220
+        }
221
+        output.writeStartElement("path");
222
+        output.writeAttribute("class", "domain");
223
+        output.writeAttribute("d", "M0,6V0H" + ((items[i].plots.length * 179) - 16) + "V6");
224
+        output.writeEndElement(); //path
225
+        output.writeEndElement(); //g
226
+        output.writeStartElement("text") //chart title
227
+        output.writeAttribute("x", (84 + (items[i].plots.length * 179))/2);
228
+        output.writeAttribute("y", "15");
229
+        output.writeAttribute("text-anchor", "middle");
230
+        output.writeAttribute("style", "font-size: 18px;");
231
+        output.writeCharacters(items[i].name);
217 232
         output.writeEndElement(); //text
218 233
         output.writeEndElement(); //g
234
+        output.writeEndElement(); //svg
219 235
     }
220
-    output.writeStartElement("path");
221
-    output.writeAttribute("class", "domain");
222
-    output.writeAttribute("d", "M0,6V0H" + ((items[i].plots.length * 179) - 16) + "V6");
223
-    output.writeEndElement(); //path
224
-    output.writeEndElement(); //g
225
-    output.writeStartElement("text") //chart title
226
-    output.writeAttribute("x", (84 + (items[i].plots.length * 179))/2);
227
-    output.writeAttribute("y", "15");
228
-    output.writeAttribute("text-anchor", "middle");
229
-    output.writeAttribute("style", "font-size: 18px;");
230
-    output.writeCharacters(items[i].name);
231
-    output.writeEndElement(); //text
232
-    output.writeEndElement(); //g
233
-    output.writeEndElement(); //svg
234
-}
235
-output.writeEndElement(); //body
236
-output.writeEndElement(); //html
237
-output.writeEndDocument();
238
-report.setContent(buffer);
239
-buffer.close();
236
+    output.writeEndElement(); //body
237
+    output.writeEndElement(); //html
238
+    output.writeEndDocument();
239
+    report.setContent(buffer);
240
+    buffer.close();
241
+};
242
+refresh();
243
+var notifier = Application.subscribe("roastinglogchange");
244
+notifier.notify.connect(function() {
245
+    refresh();
246
+});
240 247
         ]]>
241 248
     </program>
242
-</window>
249
+</window>

+ 4
- 0
config/Reports/monthcompare.xml View File

@@ -171,6 +171,10 @@
171 171
                 buffer.close();
172 172
             }
173 173
             refresh();
174
+            var notifier = Application.subscribe("roastinglogchange");
175
+            notifier.notify.connect(function() {
176
+                refresh();
177
+            });
174 178
         ]]>
175 179
     </program>
176 180
 </window>

+ 4
- 0
config/Reports/productionsummary.xml View File

@@ -177,6 +177,10 @@
177 177
             }
178 178
             refresh();
179 179
             dateSelect.rangeUpdated.connect(refresh);
180
+            var notifier = Application.subscribe("roastinglogchange");
181
+            notifier.notify.connect(function() {
182
+                refresh();
183
+            });
180 184
             view.scriptLinkClicked.connect(function(url) {
181 185
                 var arg = url.slice(1, url.length).split("-");
182 186
                 var details = createReport("dailyproductiondetail.xml");

+ 4
- 0
config/Reports/reminders.xml View File

@@ -175,6 +175,10 @@
175 175
             var doRefresh = function() {
176 176
                 refresh();
177 177
             }
178
+            var notifier = Application.subscribe("roastinglogchange");
179
+            notifier.notify.connect(function() {
180
+                refresh();
181
+            });
178 182
             report.scriptLinkClicked.connect(function(url) {
179 183
                 var reminder = createWindow("editreminder");
180 184
                 if(url != "0")

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

@@ -322,6 +322,11 @@
322 322
             query.exec("CREATE TABLE IF NOT EXISTS scheduled_roasts (id bigserial PRIMARY KEY, machine bigint, \"time\" timestamp without time zone, data jsonb NOT NULL)");
323 323
             query.exec("CREATE OR REPLACE FUNCTION notify_scheduled_roasts_changed() RETURNS trigger AS $$ BEGIN NOTIFY ScheduledRoastsChange; RETURN NULL; END; $$ LANGUAGE plpgsql");
324 324
             query.exec("CREATE TRIGGER notify_scheduled_roasts_changed AFTER INSERT OR UPDATE OR DELETE OR TRUNCATE ON scheduled_roasts FOR EACH STATEMENT EXECUTE PROCEDURE notify_scheduled_roasts_changed()");
325
+            query.exec("CREATE OR REPLACE FUNCTION notify_transactions_changed() RETURNS trigger AS $$ BEGIN NOTIFY TransactionsChange; RETURN NULL; END; $$ LANGUAGE plpgsql");
326
+            query.exec("CREATE TRIGGER notify_transactions_changed AFTER INSERT OR UPDATE OR DELETE ON transactions FOR EACH STATEMENT EXECUTE PROCEDURE notify_transactions_changed()");
327
+            query.exec("CREATE OR REPLACE FUNCTION notify_purchase_changed() RETURNS trigger AS $$ BEGIN NOTIFY PurchaseChange; RETURN NULL; END; $$ LANGUAGE plpgsql");
328
+            query.exec("CREATE TRIGGER notify_purchase_changed AFTER INSERT OR UPDATE OR DELETE ON purchase FOR EACH STATEMENT EXECUTE PROCEDURE notify_purchase_changed()");
329
+            
325 330
             query.exec("UPDATE TypicaFeatures SET version = 8 WHERE feature = 'base-features'");
326 331
             query = query.invalidate();
327 332
         };

Loading…
Cancel
Save