Typica is a free program for professional coffee roasters. https://typica.us
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rwacp.xml 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <window id="productionreport">
  2. <reporttitle>Production:->Recent Average Weekly Coffee Production</reporttitle>
  3. <layout type="vertical">
  4. <layout type="horizontal">
  5. <label>Sort Order:</label>
  6. <sqldrop id="sort" />
  7. <label>Weight Unit:</label>
  8. <sqldrop id="unit" />
  9. <stretch />
  10. </layout>
  11. <webview id="report" />
  12. </layout>
  13. <menu name="File">
  14. <item id="print" shortcut="Ctrl+P">Print</item>
  15. </menu>
  16. <program>
  17. <![CDATA[
  18. this.windowTitle = "Typica - Recent Average Weekly Coffee Production";
  19. var report = findChildObject(this, 'report');
  20. var printMenu = findChildObject(this, 'print');
  21. printMenu.triggered.connect(function() {
  22. report.print();
  23. });
  24. var sortBox = findChildObject(this, 'sort');
  25. sortBox.addItem("Roasted Coffee A-Z");
  26. sortBox.addItem("Roasted Coffee Z-A");
  27. sortBox.addItem("Weekly Use Ascending");
  28. sortBox.addItem("Weekly Use Descending");
  29. sortBox.currentIndex = QSettings.value("rwacp_sort", 3);
  30. var unitBox = findChildObject(this, 'unit');
  31. unitBox.addItem("Kg");
  32. unitBox.addItem("Lb");
  33. unitBox.currentIndex = QSettings.value("script/report_unit", 1);
  34. function refresh() {
  35. var buffer = new QBuffer;
  36. buffer.open(3);
  37. var output = new XmlWriter(buffer);
  38. output.writeStartDocument("1.0");
  39. output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
  40. output.writeStartElement("html");
  41. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  42. output.writeStartElement("head");
  43. output.writeTextElement("title", "Recent Average Weekly Coffee Production");
  44. output.writeEndElement();
  45. output.writeStartElement("body");
  46. output.writeTextElement("h1", "Recent Average Weekly Coffee Production");
  47. switch(unitBox.currentIndex)
  48. {
  49. case 0:
  50. output.writeTextElement("p", "This is a report of average weekly coffee production in kilograms over the past 28 days.");
  51. break;
  52. case 1:
  53. output.writeTextElement("p", "This is a report of average weekly coffee production in pounds over the past 28 days.");
  54. break;
  55. }
  56. output.writeStartElement("table");
  57. output.writeAttribute("rules", "groups");
  58. output.writeAttribute("cellpadding", "3px");
  59. output.writeStartElement("thead");
  60. output.writeStartElement("tr");
  61. output.writeTextElement("th", "Roasted Coffee");
  62. output.writeTextElement("th", "Weekly Use");
  63. output.writeEndElement();
  64. output.writeEndElement();
  65. output.writeStartElement("tbody");
  66. var q = "SELECT (SELECT name FROM items WHERE id = roasted_id) AS name, ((sum(roasted_quantity) / 4) / :conversion)::numeric(18,2) AS weekly FROM roasting_log WHERE time > current_date - integer '28' AND roasted_quantity > 0 GROUP BY roasted_id ORDER BY "
  67. switch(sortBox.currentIndex)
  68. {
  69. case 0:
  70. q += "name ASC";
  71. break;
  72. case 1:
  73. q += "name DESC";
  74. break;
  75. case 2:
  76. q += "weekly ASC";
  77. break;
  78. case 3:
  79. q += "weekly DESC";
  80. break;
  81. }
  82. var query = new QSqlQuery();
  83. query.prepare(q);
  84. switch(unitBox.currentIndex)
  85. {
  86. case 0:
  87. query.bind(":conversion", 2.2);
  88. break;
  89. case 1:
  90. query.bind(":conversion", 1);
  91. break;
  92. }
  93. query.exec();
  94. while(query.next())
  95. {
  96. output.writeStartElement("tr");
  97. output.writeTextElement("td", query.value(0));
  98. output.writeTextElement("td", query.value(1));
  99. output.writeEndElement();
  100. }
  101. output.writeEndElement();
  102. output.writeStartElement("tfoot")
  103. output.writeTextElement("th", "Total");
  104. query.prepare("SELECT (sum(roasted_quantity) / 4 / :conversion)::numeric(18,2) FROM roasting_log WHERE time > current_date - integer '28' AND roasted_quantity > 0");
  105. switch(unitBox.currentIndex)
  106. {
  107. case 0:
  108. query.bind(":conversion", 2.2);
  109. break;
  110. case 1:
  111. query.bind(":conversion", 1);
  112. break;
  113. }
  114. query.exec();
  115. query.next();
  116. output.writeTextElement("td", query.value(0));
  117. output.writeEndElement();
  118. output.writeEndElement();
  119. output.writeEndElement();
  120. output.writeEndElement();
  121. output.writeEndDocument();
  122. report.setContent(buffer);
  123. buffer.close();
  124. }
  125. refresh();
  126. sortBox['currentIndexChanged(int)'].connect(function() {
  127. QSettings.setValue("rwacp_sort", sortBox.currentIndex);
  128. refresh();
  129. });
  130. unitBox['currentIndexChanged(int)'].connect(function() {
  131. QSettings.setValue("script/report_unit", unitBox.currentIndex);
  132. refresh();
  133. });
  134. ]]>
  135. </program>
  136. </window>