Browse Source

Add table representation of chart data to item transaction summary

Neal Wilson 8 years ago
parent
commit
6899980aa3
1 changed files with 31 additions and 0 deletions
  1. 31
    0
      config/Reports/itemtransactions.xml

+ 31
- 0
config/Reports/itemtransactions.xml View File

175
 					output.writeCDATA(scriptFile.readToString());
175
 					output.writeCDATA(scriptFile.readToString());
176
 					scriptFile.close();
176
 					scriptFile.close();
177
 					output.writeEndElement();
177
 					output.writeEndElement();
178
+
179
+                                        eval(chartData);
180
+                                        output.writeStartElement("table");
181
+                                        output.writeStartElement("tr");
182
+                                        output.writeTextElement("th", "Item");
183
+                                        output.writeTextElement("th", "Green");
184
+                                        output.writeTextElement("th", "Roasted");
185
+                                        output.writeTextElement("th", "Transactions");
186
+                                        output.writeEndElement();
187
+                                        for(var r = 0; r < data.length; r++)
188
+                                        {
189
+                                            output.writeStartElement("tr");
190
+                                            output.writeTextElement("td", data[r][0]);
191
+                                            output.writeTextElement("td", data[r][1]);
192
+                                            output.writeTextElement("td", data[r][3]);
193
+                                            output.writeTextElement("td", data[r][2]);
194
+                                            output.writeEndElement();
195
+                                        }
196
+                                        output.writeStartElement("tr");
197
+                                        output.writeTextElement("th", "Totals:");
198
+                                        output.writeTextElement("td", data.reduce(function(prev, current){
199
+                                            return +(current[1]) + prev;
200
+                                        }, 0));
201
+                                        output.writeTextElement("td", data.reduce(function(prev, current){
202
+                                            return +(current[3]) + prev;
203
+                                        }, 0));
204
+                                        output.writeTextElement("td", data.reduce(function(prev, current){
205
+                                            return +(current[2]) + prev;
206
+                                        }, 0));
207
+                                        output.writeEndElement();
208
+                                        output.writeEndElement();
178
 					
209
 					
179
 					query.prepare("SELECT time::date, type, quantity / :c1, balance / :c2, (SELECT files FROM roasting_log WHERE roasting_log.time = item_history.time AND item = ANY(unroasted_id)), (SELECT invoice_id FROM invoice_items WHERE item = item_id AND item_history.type = 'PURCHASE'), (SELECT vendor || ' ' || invoice FROM invoices WHERE id = (SELECT invoice_id FROM invoice_items WHERE item = item_id AND item_history.type = 'PURCHASE')), (SELECT name FROM items WHERE id = (SELECT roasted_id FROM roasting_log WHERE roasting_log.time = item_history.time AND item = ANY(unroasted_id))), customer, reason FROM item_history(:item)");
210
 					query.prepare("SELECT time::date, type, quantity / :c1, balance / :c2, (SELECT files FROM roasting_log WHERE roasting_log.time = item_history.time AND item = ANY(unroasted_id)), (SELECT invoice_id FROM invoice_items WHERE item = item_id AND item_history.type = 'PURCHASE'), (SELECT vendor || ' ' || invoice FROM invoices WHERE id = (SELECT invoice_id FROM invoice_items WHERE item = item_id AND item_history.type = 'PURCHASE')), (SELECT name FROM items WHERE id = (SELECT roasted_id FROM roasting_log WHERE roasting_log.time = item_history.time AND item = ANY(unroasted_id))), customer, reason FROM item_history(:item)");
180
 					switch(unitBox.currentIndex)
211
 					switch(unitBox.currentIndex)

Loading…
Cancel
Save