|
|
|
|
24
|
query.exec("SELECT EXTRACT(YEAR FROM time) FROM purchase WHERE time = (SELECT min(time) FROM purchase)");
|
24
|
query.exec("SELECT EXTRACT(YEAR FROM time) FROM purchase WHERE time = (SELECT min(time) FROM purchase)");
|
25
|
query.next();
|
25
|
query.next();
|
26
|
startDateField.setDate(query.value(0), 1, 1);
|
26
|
startDateField.setDate(query.value(0), 1, 1);
|
|
|
27
|
+ query = query.invalidate();
|
27
|
/* Set ending year to the current year. */
|
28
|
/* Set ending year to the current year. */
|
28
|
var endDateField = findChildObject(this, 'enddate');
|
29
|
var endDateField = findChildObject(this, 'enddate');
|
29
|
endDateField.setDate(endDateField.year(), 12, 31);
|
30
|
endDateField.setDate(endDateField.year(), 12, 31);
|
|
|
|
|
79
|
var sacktotal = 0;
|
80
|
var sacktotal = 0;
|
80
|
var unittotal = 0;
|
81
|
var unittotal = 0;
|
81
|
var costtotal = 0;
|
82
|
var costtotal = 0;
|
|
|
83
|
+ var query = new QSqlQuery();
|
82
|
for(var i = startDateField.year(); i <= endDateField.year(); i++)
|
84
|
for(var i = startDateField.year(); i <= endDateField.year(); i++)
|
83
|
{
|
85
|
{
|
84
|
- output.writeStartElement("tr");
|
|
|
85
|
- output.writeAttribute("id", "y"+i);
|
|
|
86
|
var q = "SELECT sum(quantity/(SELECT conversion FROM lb_bag_conversion WHERE item = purchase.item)), (sum(quantity) / :conversion)::numeric(12,2), sum(cost*quantity)::numeric(12,2) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
|
86
|
var q = "SELECT sum(quantity/(SELECT conversion FROM lb_bag_conversion WHERE item = purchase.item)), (sum(quantity) / :conversion)::numeric(12,2), sum(cost*quantity)::numeric(12,2) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
|
87
|
query.prepare(q);
|
87
|
query.prepare(q);
|
|
|
88
|
+ output.writeStartElement("tr");
|
|
|
89
|
+ output.writeAttribute("id", "y"+i);
|
88
|
query.bind(":conversion", unitBox.currentIndex == 0 ? 2.2 : 1);
|
90
|
query.bind(":conversion", unitBox.currentIndex == 0 ? 2.2 : 1);
|
89
|
query.exec();
|
91
|
query.exec();
|
90
|
query.next();
|
92
|
query.next();
|
|
|
|
|
99
|
costtotal += Number(query.value(2));
|
101
|
costtotal += Number(query.value(2));
|
100
|
output.writeEndElement(); //tr
|
102
|
output.writeEndElement(); //tr
|
101
|
}
|
103
|
}
|
|
|
104
|
+ query = query.invalidate();
|
102
|
output.writeEndElement(); //tbody
|
105
|
output.writeEndElement(); //tbody
|
103
|
output.writeStartElement("tfoot");
|
106
|
output.writeStartElement("tfoot");
|
104
|
output.writeTextElement("th", "Totals:");
|
107
|
output.writeTextElement("th", "Totals:");
|