|
|
|
|
14
|
</menu>
|
14
|
</menu>
|
15
|
<program>
|
15
|
<program>
|
16
|
<![CDATA[
|
16
|
<![CDATA[
|
17
|
- this.windowTitle = "Typica - Green Coffee Sales";
|
|
|
|
|
17
|
+ this.windowTitle = TTR("greensales", "Typica - Green Coffee Sales");
|
18
|
var dateSelect = findChildObject(this, 'dates');
|
18
|
var dateSelect = findChildObject(this, 'dates');
|
19
|
var dateQuery = new QSqlQuery();
|
19
|
var dateQuery = new QSqlQuery();
|
20
|
dateQuery.exec("SELECT time::date FROM sale WHERE time = (SELECT min(time) FROM sale) OR time = (SELECT max(time) FROM sale) ORDER BY time ASC");
|
20
|
dateQuery.exec("SELECT time::date FROM sale WHERE time = (SELECT min(time) FROM sale) OR time = (SELECT max(time) FROM sale) ORDER BY time ASC");
|
|
|
|
|
29
|
dateSelect.setLifetimeRange(lifetimeStartDate, lifetimeEndDate);
|
29
|
dateSelect.setLifetimeRange(lifetimeStartDate, lifetimeEndDate);
|
30
|
dateQuery = dateQuery.invalidate();
|
30
|
dateQuery = dateQuery.invalidate();
|
31
|
var unitBox = findChildObject(this, 'unit');
|
31
|
var unitBox = findChildObject(this, 'unit');
|
32
|
- unitBox.addItem("Kg");
|
|
|
33
|
- unitBox.addItem("Lb");
|
|
|
|
|
32
|
+ unitBox.addItem(TTR("greensales", "Kg"));
|
|
|
33
|
+ unitBox.addItem(TTR("greensales", "Lb"));
|
34
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
34
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
35
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
35
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
36
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
36
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
|
|
|
|
51
|
output.writeStartElement("html");
|
51
|
output.writeStartElement("html");
|
52
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
52
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
53
|
output.writeStartElement("head");
|
53
|
output.writeStartElement("head");
|
54
|
- output.writeTextElement("title", "Green Coffee Sales");
|
|
|
|
|
54
|
+ output.writeTextElement("title", TTR("greensales", "Green Coffee Sales"));
|
55
|
output.writeEndElement();
|
55
|
output.writeEndElement();
|
56
|
output.writeStartElement("body");
|
56
|
output.writeStartElement("body");
|
57
|
var dateRange = dateSelect.currentRange();
|
57
|
var dateRange = dateSelect.currentRange();
|
58
|
var startDate = dateRange[0];
|
58
|
var startDate = dateRange[0];
|
59
|
var endDate = dateRange[dateRange.length - 1];
|
59
|
var endDate = dateRange[dateRange.length - 1];
|
60
|
- output.writeTextElement("h1", "Green Coffee Sales: " + startDate + " - " + endDate);
|
|
|
|
|
60
|
+ output.writeTextElement("h1", TTR("greensales", "Green Coffee Sales: ") + startDate + " - " + endDate);
|
61
|
var conversion = 1;
|
61
|
var conversion = 1;
|
62
|
- var unitText = 'Lb';
|
|
|
|
|
62
|
+ var unitText = TTR("greensales", "Lb");
|
63
|
if(unitBox.currentIndex == 0) {
|
63
|
if(unitBox.currentIndex == 0) {
|
64
|
conversion = 2.2;
|
64
|
conversion = 2.2;
|
65
|
- unitText = 'Kg';
|
|
|
|
|
65
|
+ unitText = TTR("greensales", "Kg");
|
66
|
}
|
66
|
}
|
67
|
var query = new QSqlQuery();
|
67
|
var query = new QSqlQuery();
|
68
|
query.prepare("SELECT item, (SELECT name FROM coffees WHERE id = item) AS name, (SELECT origin FROM coffees WHERE id = item) AS origin, (SELECT reference FROM coffees WHERE id = item) AS reference, (SUM(quantity)/:conversion)::numeric(12,3) FROM sale WHERE time < :ed ::date + interval '1 day' AND time >= :sd GROUP BY item ORDER BY name ASC");
|
68
|
query.prepare("SELECT item, (SELECT name FROM coffees WHERE id = item) AS name, (SELECT origin FROM coffees WHERE id = item) AS origin, (SELECT reference FROM coffees WHERE id = item) AS reference, (SUM(quantity)/:conversion)::numeric(12,3) FROM sale WHERE time < :ed ::date + interval '1 day' AND time >= :sd GROUP BY item ORDER BY name ASC");
|
|
|
|
|
75
|
output.writeAttribute("cellpadding", "3px");
|
75
|
output.writeAttribute("cellpadding", "3px");
|
76
|
output.writeStartElement("thead");
|
76
|
output.writeStartElement("thead");
|
77
|
output.writeStartElement("tr");
|
77
|
output.writeStartElement("tr");
|
78
|
- output.writeTextElement("th", "ID"); // 0
|
|
|
79
|
- output.writeTextElement("th", "Coffee"); // 1
|
|
|
80
|
- output.writeTextElement("th", "Origin"); // 2
|
|
|
81
|
- output.writeTextElement("th", "Reference"); // 3
|
|
|
82
|
- output.writeTextElement("th", "Quantity"); // 4
|
|
|
|
|
78
|
+ output.writeTextElement("th", TTR("greensales", "ID")); // 0
|
|
|
79
|
+ output.writeTextElement("th", TTR("greensales", "Coffee")); // 1
|
|
|
80
|
+ output.writeTextElement("th", TTR("greensales", "Origin")); // 2
|
|
|
81
|
+ output.writeTextElement("th", TTR("greensales", "Reference")); // 3
|
|
|
82
|
+ output.writeTextElement("th", TTR("greensales", "Quantity")); // 4
|
83
|
output.writeEndElement();
|
83
|
output.writeEndElement();
|
84
|
output.writeEndElement();
|
84
|
output.writeEndElement();
|
85
|
output.writeStartElement("tbody");
|
85
|
output.writeStartElement("tbody");
|
|
|
|
|
106
|
output.writeEmptyElement("td");
|
106
|
output.writeEmptyElement("td");
|
107
|
output.writeEmptyElement("td");
|
107
|
output.writeEmptyElement("td");
|
108
|
output.writeEmptyElement("td");
|
108
|
output.writeEmptyElement("td");
|
109
|
- output.writeTextElement("th", "Total:");
|
|
|
|
|
109
|
+ output.writeTextElement("th", TTR("greensales", "Total:"));
|
110
|
output.writeTextElement("td", query.value(0));
|
110
|
output.writeTextElement("td", query.value(0));
|
111
|
output.writeEndElement();
|
111
|
output.writeEndElement();
|
112
|
}
|
112
|
}
|