Typica is a free program for professional coffee roasters. https://typica.us
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <window id="pytdprodcomp">
  2. <reporttitle>Production:->Previous Year Production Comparison By Month</reporttitle>
  3. <layout type="vertical">
  4. <layout type="horizontal">
  5. <label>Weight Unit:</label>
  6. <sqldrop id="unit" />
  7. <stretch />
  8. </layout>
  9. <webview id="report" />
  10. </layout>
  11. <menu name="File">
  12. <item id="print" shortcut="Ctrl+P">Print</item>
  13. </menu>
  14. <program>
  15. <![CDATA[
  16. this.windowTitle = TTR("pytdprodcomp", "Typica - Previous Year Production Comparison By Month");
  17. var view = findChildObject(this, 'report');
  18. var printMenu = findChildObject(this, 'print');
  19. printMenu.triggered.connect(function() {
  20. view.print();
  21. });
  22. var unitBox = findChildObject(this, 'unit');
  23. unitBox.addItem(TTR("pytdprodcomp", "Kg"));
  24. unitBox.addItem(TTR("pytdprodcomp", "Lb"));
  25. unitBox.currentIndex = QSettings.value("script/report_unit", 1);
  26. unitBox['currentIndexChanged(int)'].connect(function() {
  27. QSettings.setValue("script/report_unit", unitBox.currentIndex);
  28. refresh();
  29. });
  30. function refresh() {
  31. var buffer = new QBuffer;
  32. buffer.open(3);
  33. var output = new XmlWriter(buffer);
  34. output.writeStartDocument("1.0");
  35. 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">');
  36. output.writeStartElement("html");
  37. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  38. output.writeStartElement("head");
  39. output.writeTextElement("title", TTR("pytdprodcomp", "Previous Year Production Comparison By Month"));
  40. output.writeEndElement();
  41. output.writeStartElement("body");
  42. output.writeTextElement("h1", TTR("pytdprodcomp", "Previous Year Production Comparison By Month"));
  43. switch(unitBox.currentIndex)
  44. {
  45. case 0:
  46. output.writeTextElement("p", TTR("pytdprodcomp", "This report compares total roasted coffee production in kilograms with the previous year on a monthly basis."));
  47. break;
  48. case 1:
  49. output.writeTextElement("p", TTR("pytdprodcomp", "This report compares total roasted coffee production in pounds with the previous year on a monthly basis."));
  50. break;
  51. }
  52. output.writeStartElement("table");
  53. output.writeAttribute("style", "page-break-after:auto;");
  54. output.writeAttribute("rules", "groups");
  55. output.writeAttribute("cellpadding", "3px");
  56. output.writeStartElement("thead");
  57. output.writeStartElement("tr");
  58. output.writeTextElement("th", TTR("pytdprodcomp", "Month"));
  59. var query = new QSqlQuery();
  60. query.exec("SELECT EXTRACT(YEAR FROM 'now'::date) AS current_year");
  61. query.next();
  62. var current_year = query.value(0);
  63. output.writeTextElement("th", current_year-1);
  64. output.writeTextElement("th", current_year);
  65. output.writeTextElement("th", "Change");
  66. output.writeEndElement();
  67. output.writeEndElement();
  68. output.writeStartElement("tbody");
  69. var month_names = [TTR("pytdprodcomp", "January"),
  70. TTR("pytdprodcomp", "February"),
  71. TTR("pytdprodcomp", "March"),
  72. TTR("pytdprodcomp", "April"),
  73. TTR("pytdprodcomp", "May"),
  74. TTR("pytdprodcomp", "June"),
  75. TTR("pytdprodcomp", "July"),
  76. TTR("pytdprodcomp", "August"),
  77. TTR("pytdprodcomp", "September"),
  78. TTR("pytdprodcomp", "October"),
  79. TTR("pytdprodcomp", "November"),
  80. TTR("pytdprodcomp", "December")];
  81. var current_data = new Array();
  82. var previous_data = new Array();
  83. for(var i = 0; i < 12; i++) {
  84. var q = "SELECT SUM(roasted_quantity) FROM roasting_log WHERE roasted_id IS NOT NULL AND time > '"
  85. q += current_year;
  86. q += "-";
  87. q += 1+i;
  88. q += "-01' AND time < '";
  89. if(i == 11) {
  90. q += 1+current_year;
  91. } else {
  92. q += current_year;
  93. }
  94. q += "-";
  95. if(i == 11) {
  96. q += "01"
  97. } else {
  98. q += 2+i;
  99. }
  100. q += "-01'";
  101. query.exec(q);
  102. query.next();
  103. current_data.push(query.value(0));
  104. }
  105. for(var i = 0; i < 12; i++) {
  106. var q = "SELECT SUM(roasted_quantity) FROM roasting_log WHERE roasted_id IS NOT NULL AND time > '"
  107. q += current_year-1;
  108. q += "-";
  109. q += 1+i;
  110. q += "-01' AND time < '";
  111. if(i == 11) {
  112. q += current_year;
  113. } else {
  114. q += current_year-1;
  115. }
  116. q += "-";
  117. if(i == 11) {
  118. q += "01"
  119. } else {
  120. q += 2+i;
  121. }
  122. q += "-01'";
  123. query.exec(q);
  124. query.next();
  125. previous_data.push(query.value(0));
  126. }
  127. query = query.invalidate();
  128. for(var i = 0; i < 12; i++) {
  129. output.writeStartElement("tr");
  130. output.writeTextElement("td", month_names[i]);
  131. switch(unitBox.currentIndex)
  132. {
  133. case 0:
  134. output.writeTextElement("td", Number(previous_data[i] / 2.2).toFixed(2));
  135. output.writeTextElement("td", Number(current_data[i] / 2.2).toFixed(2));
  136. output.writeTextElement("td", Number((current_data[i] - previous_data[i]) / 2.2).toFixed(2));
  137. break;
  138. case 1:
  139. output.writeTextElement("td", Number(previous_data[i]).toFixed(2));
  140. output.writeTextElement("td", Number(current_data[i]).toFixed(2));
  141. output.writeTextElement("td", Number(current_data[i]-previous_data[i]).toFixed(2));
  142. break;
  143. }
  144. output.writeEndElement();
  145. }
  146. output.writeEndElement();
  147. output.writeStartElement("tfoot");
  148. output.writeTextElement("th", TTR("pytdprodcomp", "Totals"));
  149. var current_total = current_data.reduce(function(a,b) {return Number(a) + Number(b);}, 0);
  150. var previous_total = previous_data.reduce(function(a,b) {return Number(a) + Number(b);}, 0);
  151. switch(unitBox.currentIndex)
  152. {
  153. case 0:
  154. output.writeTextElement("td", (previous_total/2.2).toFixed(2));
  155. output.writeTextElement("td", (current_total/2.2).toFixed(2));
  156. output.writeTextElement("td", ((current_total-previous_total)/2.2).toFixed(2));
  157. break;
  158. case 1:
  159. output.writeTextElement("td", previous_total.toFixed(2));
  160. output.writeTextElement("td", current_total.toFixed(2));
  161. output.writeTextElement("td", (current_total-previous_total).toFixed(2));
  162. break;
  163. }
  164. output.writeEndElement();
  165. output.writeEndElement();
  166. output.writeEndElement();
  167. output.writeEndDocument();
  168. view.setContent(buffer);
  169. buffer.close();
  170. }
  171. refresh();
  172. ]]>
  173. </program>
  174. </window>