Browse Source

Add bag size information to AUCO report.

Neal Wilson 10 years ago
parent
commit
6c1ff99133
1 changed files with 19 additions and 4 deletions
  1. 19
    4
      config/Reports/auco.xml

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

@@ -65,7 +65,7 @@
65 65
                 output.writeStartElement("thead");
66 66
                 output.writeStartElement("tr");
67 67
                 output.writeStartElement("th");
68
-                output.writeAttribute("colspan", "5");
68
+                output.writeAttribute("colspan", "8");
69 69
                 output.writeCharacters("Regular Coffees");
70 70
                 output.writeEndElement();
71 71
                 output.writeEndElement();
@@ -75,6 +75,9 @@
75 75
                 output.writeTextElement("th", "Avg. Cost");
76 76
 				output.writeTextElement("th", "Last Cost");
77 77
 				output.writeTextElement("th", "Last Purchase Date");
78
+				output.writeTextElement("th", "Bag Size (min)");
79
+				output.writeTextElement("th", "Bag Size (max)");
80
+				output.writeTextElement("th", "Bag Size (mean)");
78 81
                 output.writeEndElement();
79 82
                 output.writeEndElement();
80 83
                 output.writeStartElement("tbody");
@@ -105,10 +108,13 @@
105 108
 						orderClause = "cost DESC";
106 109
 						break;
107 110
 				}
108
-				query.prepare("SELECT DISTINCT origin, (avg(rate)/:conversion)::numeric(10,2) AS rate, (SELECT avg(cost)*:conversion2 FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS cost, (SELECT avg(cost)*:conversion3 FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin) AND time = (SELECT max(time) FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))), (SELECT max(time)::date FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin)) FROM coffee_history WHERE id IN (SELECT id FROM regular_coffees) GROUP BY origin ORDER BY " + orderClause);
111
+				query.prepare("SELECT DISTINCT origin, (avg(rate)/:conversion)::numeric(10,2) AS rate, (SELECT avg(cost)*:conversion2 FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS cost, (SELECT avg(cost)*:conversion3 FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin) AND time = (SELECT max(time) FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))), (SELECT max(time)::date FROM purchase WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin)), (SELECT min(conversion)/:conversion4 FROM lb_bag_conversion WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS minbag, (SELECT max(conversion)/:conversion5 FROM lb_bag_conversion WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS maxbag, (SELECT avg(conversion)/:conversion6 FROM lb_bag_conversion WHERE item IN (SELECT id FROM regular_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS meanbag FROM coffee_history WHERE id IN (SELECT id FROM regular_coffees) GROUP BY origin ORDER BY " + orderClause);
109 112
 				query.bind(":conversion", conversion);
110 113
 				query.bind(":conversion2", conversion);
111 114
 				query.bind(":conversion3", conversion);
115
+				query.bind(":conversion4", conversion);
116
+				query.bind(":conversion5", conversion);
117
+				query.bind(":conversion6", conversion);
112 118
 				query.exec();
113 119
                 while(query.next())
114 120
                 {
@@ -118,18 +124,24 @@
118 124
                     output.writeTextElement("td", query.value(2));
119 125
 					output.writeTextElement("td", query.value(3));
120 126
 					output.writeTextElement("td", query.value(4));
127
+					output.writeTextElement("td", query.value(5));
128
+					output.writeTextElement("td", query.value(6));
129
+					output.writeTextElement("td", query.value(7));
121 130
                     output.writeEndElement();
122 131
                 }
123 132
                 output.writeStartElement("tr");
124 133
                 output.writeStartElement("th");
125
-                output.writeAttribute("colspan", "5");
134
+                output.writeAttribute("colspan", "8");
126 135
                 output.writeCharacters("Decaffeinated Coffees");
127 136
                 output.writeEndElement();
128 137
                 output.writeEndElement();
129
-				query.prepare("SELECT DISTINCT origin, (avg(rate)/:conversion)::numeric(10,2) AS rate, (SELECT avg(cost)*:conversion2 FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS cost, (SELECT avg(cost)*:conversion3 FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin) AND time = (SELECT max(time) FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))), (SELECT max(time)::date FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin)) FROM coffee_history WHERE id IN (SELECT id FROM decaf_coffees) GROUP BY origin ORDER BY " + orderClause);
138
+				query.prepare("SELECT DISTINCT origin, (avg(rate)/:conversion)::numeric(10,2) AS rate, (SELECT avg(cost)*:conversion2 FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS cost, (SELECT avg(cost)*:conversion3 FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin) AND time = (SELECT max(time) FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))), (SELECT max(time)::date FROM purchase WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin)), (SELECT min(conversion)/:conversion4 FROM lb_bag_conversion WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS minbag, (SELECT max(conversion)/:conversion5 FROM lb_bag_conversion WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS maxbag, (SELECT avg(conversion)/:conversion6 FROM lb_bag_conversion WHERE item IN (SELECT id FROM decaf_coffees WHERE origin = coffee_history.origin))::numeric(10,2) AS meanbag FROM coffee_history WHERE id IN (SELECT id FROM decaf_coffees) GROUP BY origin ORDER BY " + orderClause);
130 139
 				query.bind(":conversion", conversion);
131 140
 				query.bind(":conversion2", conversion);
132 141
 				query.bind(":conversion3", conversion);
142
+				query.bind(":conversion4", conversion);
143
+				query.bind(":conversion5", conversion);
144
+				query.bind(":conversion6", conversion);
133 145
 				query.exec();
134 146
                 while(query.next())
135 147
                 {
@@ -139,6 +151,9 @@
139 151
                     output.writeTextElement("td", query.value(2));
140 152
 					output.writeTextElement("td", query.value(3));
141 153
 					output.writeTextElement("td", query.value(4));
154
+					output.writeTextElement("td", query.value(5));
155
+					output.writeTextElement("td", query.value(6));
156
+					output.writeTextElement("td", query.value(7));
142 157
                     output.writeEndElement();
143 158
                 }
144 159
 				query = query.invalidate();

Loading…
Cancel
Save