Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

history.xml 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <window id="history">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <daterange id="dates" initial="6" /><!-- Last 7 Days -->
  5. <stretch />
  6. </layout>
  7. <sqlview id="table" />
  8. </layout>
  9. <program>
  10. <![CDATA[
  11. var dateSelect = findChildObject(this, 'dates');
  12. var dateQuery = new QSqlQuery();
  13. dateQuery.exec("SELECT time::date FROM roasting_log WHERE time = (SELECT min(time) FROM roasting_log) OR time = (SELECT max(time) FROM roasting_log) ORDER BY time ASC");
  14. dateQuery.next();
  15. var lifetimeStartDate = dateQuery.value(0);
  16. var lifetimeEndDate;
  17. if(dateQuery.next()) {
  18. lifetimeEndDate = dateQuery.value(0);
  19. } else {
  20. lifetimeEndDate = lifetimeStartDate;
  21. }
  22. dateSelect.setLifetimeRange(lifetimeStartDate, lifetimeEndDate);
  23. dateQuery.invalidate();
  24. var table = findChildObject(this, 'table');
  25. table.openEntryRow.connect(function(arg) {
  26. var details = createWindow("batchDetails");
  27. details.loadData(table, arg);
  28. });
  29. function refresh() {
  30. var dateRange = dateSelect.currentRange();
  31. var startDate = "'"+dateRange[0]+"'";
  32. var endDate = "'"+dateRange[dateRange.length - 1]+"'";
  33. var q = "SELECT time, machine, (SELECT name FROM items WHERE id = roasted_id) AS name, unroasted_total_quantity AS green, roasted_quantity AS roasted, ((unroasted_total_quantity - roasted_quantity) / unroasted_total_quantity * 100::numeric)::numeric(12,2) AS weight_loss, duration, annotation FROM roasting_log WHERE time >= " + startDate + "::date AND time < " + endDate + "::date + interval '1 day' ORDER BY time DESC";
  34. table.setQuery(q);
  35. table.hideColumn(1);
  36. }
  37. dateSelect.rangeUpdated.connect(function() {
  38. refresh();
  39. });
  40. refresh();
  41. ]]>
  42. </program>
  43. </window>