|
@@ -2,10 +2,7 @@
|
2
|
2
|
<reporttitle>Production:->Previous Year Production Comparison</reporttitle>
|
3
|
3
|
<layout type="vertical">
|
4
|
4
|
<layout type="horizontal">
|
5
|
|
- <label>Start Date:</label>
|
6
|
|
- <calendar id="startdate" />
|
7
|
|
- <label>End Date:</label>
|
8
|
|
- <calendar id="enddate" />
|
|
5
|
+ <daterange id="dates" initial="19" /><!-- Current Year to Date -->
|
9
|
6
|
<label>Days to Average</label>
|
10
|
7
|
<line validator="integer" id="days">7</line>
|
11
|
8
|
<label>Weight Unit:</label>
|
|
@@ -20,9 +17,7 @@
|
20
|
17
|
<program>
|
21
|
18
|
<![CDATA[
|
22
|
19
|
this.windowTitle = "Typica - Previous Year Production Comparison";
|
23
|
|
- var startDateField = findChildObject(this, 'startdate');
|
24
|
|
- startDateField.setDate(startDateField.year(), 1, 1);
|
25
|
|
- var endDateField = findChildObject(this, 'enddate');
|
|
20
|
+ var dateSelect = findChildObject(this, 'dates');
|
26
|
21
|
var view = findChildObject(this, 'report');
|
27
|
22
|
var printMenu = findChildObject(this, 'print');
|
28
|
23
|
printMenu.triggered.connect(function() {
|
|
@@ -79,10 +74,12 @@
|
79
|
74
|
output.writeStartElement("tbody");
|
80
|
75
|
var query = new QSqlQuery();
|
81
|
76
|
query.exec("START TRANSACTION");
|
82
|
|
- var curStartDate = "'"+startDateField.year()+"-"+startDateField.month()+"-"+startDateField.day()+"'";
|
83
|
|
- query.exec("SELECT "+curStartDate+"::date - interval '1 year', '"+endDateField.year()+"-"+endDateField.month()+"-"+endDateField.day()+"'::date - interval '1 year' + interval '1 day', '"+endDateField.year()+"-"+endDateField.month()+"-"+endDateField.day()+"'::date + interval '1 day'");
|
84
|
|
- query.next();
|
85
|
|
- var curEndDate = "'"+query.value(2)+"'";
|
|
77
|
+ var dateRange = dateSelect.currentRange();
|
|
78
|
+ var curStartDate = "'"+dateRange[0]+"'";
|
|
79
|
+ var curEndDate = "'"+dateRange[dateRange.length - 1]+"'";
|
|
80
|
+ query.exec("SELECT "+curStartDate+"::date - interval '1 year', "+curEndDate+"::date - interval '1 year' + interval '1 day', "+curEndDate+"::date + interval '1 day'");
|
|
81
|
+ query.next();
|
|
82
|
+ curEndDate = "'"+query.value(2)+"'";
|
86
|
83
|
var prevStartDate = "'"+query.value(0)+"'";
|
87
|
84
|
var prevEndDate = "'"+query.value(1)+"'";
|
88
|
85
|
var q = "CREATE TEMPORARY TABLE previous ON COMMIT DROP AS SELECT roasted_id, sum(roasted_quantity) AS p FROM roasting_log WHERE time > "+prevStartDate+" AND time < "+prevEndDate+" AND roasted_id IS NOT NULL GROUP BY roasted_id";
|
|
@@ -501,12 +498,9 @@
|
501
|
498
|
buffer.close();
|
502
|
499
|
}
|
503
|
500
|
refresh();
|
504
|
|
- startDateField.dateChanged.connect(function() {
|
505
|
|
- refresh();
|
506
|
|
- });
|
507
|
|
- endDateField.dateChanged.connect(function() {
|
508
|
|
- refresh();
|
509
|
|
- });
|
|
501
|
+ dateSelect.rangeUpdated.connect(function() {
|
|
502
|
+ refresh();
|
|
503
|
+ });
|
510
|
504
|
avgField.editingFinished.connect(function() {
|
511
|
505
|
refresh();
|
512
|
506
|
});
|