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.

greeninventory.xml 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <window id="inventory">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <sqldrop id="transactiontype" />
  5. <stretch />
  6. </layout>
  7. <layout type="horizontal">
  8. <sqldrop data="0" display="1" showdata="true" id="item">
  9. <query><![CDATA[SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name ASC]]></query>
  10. </sqldrop>
  11. <line id="quantity" />
  12. <sqldrop id="units" />
  13. <label id="reasonlabel">Reason: </label>
  14. <line id="reason" />
  15. </layout>
  16. <layout type="horizontal">
  17. <stretch />
  18. <button type="push" name="Update" id="update" />
  19. </layout>
  20. <textarea id="current" />
  21. </layout>
  22. <program>
  23. <![CDATA[
  24. var types = findChildObject(this, 'transactiontype');
  25. types.addItem("inventory");
  26. types.addItem("loss");
  27. var units = findChildObject(this, 'units');
  28. units.addItem("bag");
  29. units.addItem("lb");
  30. units.addItem("kg");
  31. var items = findChildObject(this, 'item');
  32. var status = findChildObject(this, 'current');
  33. var q = "SELECT quantity FROM items WHERE id = ";
  34. q = q + items.currentData();
  35. query = new QSqlQuery();
  36. query.exec(q);
  37. query.next();
  38. var text = items.currentText;
  39. text = text + " Current inventory: ";
  40. text = text + query.value(0);
  41. text = text + " pounds ("
  42. text = text + Number(query.value(0)) / 2.2;
  43. text = text + " Kg (";
  44. q = "SELECT ";
  45. q = q + query.value(0);
  46. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  47. q = q + items.currentData();
  48. q = q + ")";
  49. query.exec(q);
  50. query.next();
  51. text = text + query.value(0);
  52. text = text + " bags)";
  53. query = query.invalidate();
  54. status.plainText = text;
  55. var button = findChildObject(this, 'update');
  56. var value = findChildObject(this, 'quantity');
  57. var reason = findChildObject(this, 'reason');
  58. var reasonlabel = findChildObject(this, 'reasonlabel');
  59. reason.enabled = false;
  60. button.clicked.connect(function() {
  61. q = "INSERT INTO ";
  62. q += (types.currentIndex == 0 ?
  63. "inventory (time, item, quantity)" :
  64. "loss (time, item, quantity, reason)");
  65. q += " VALUES ('now', ";
  66. q = q + items.currentData();
  67. q = q + ", ";
  68. if(units.currentText == "lb") {
  69. q = q + value.text;
  70. } else if (units.currentText == "kg") {
  71. q = q + (value.text * 2.2);
  72. }
  73. else {
  74. q = q + value.text;
  75. q = q + " * (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  76. q = q + items.currentData();
  77. q = q + ")";
  78. }
  79. q += (types.currentIndex == 0 ?
  80. ")" :
  81. ", '" + reason.text + "')");
  82. query = new QSqlQuery();
  83. query.exec(q);
  84. text = items.currentText;
  85. q = "SELECT quantity FROM items WHERE id = ";
  86. q = q + items.currentData();
  87. query.exec(q);
  88. query.next();
  89. text = text + " Current inventory: ";
  90. text = text + query.value(0);
  91. text = text + " pounds (";
  92. q = "SELECT ";
  93. q = q + query.value(0);
  94. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  95. q = q + items.currentData();
  96. q = q + ")";
  97. query.exec(q);
  98. query.next();
  99. text = text + query.value(0);
  100. text = text + " bags)";
  101. status.plainText = text;
  102. query = query.invalidate();
  103. });
  104. items['currentIndexChanged(int)'].connect(function() {
  105. q = "SELECT quantity FROM items WHERE id = ";
  106. q = q + items.currentData();
  107. query = new QSqlQuery();
  108. query.exec(q);
  109. query.next();
  110. var text = items.currentText;
  111. text = text + " Current inventory: ";
  112. text = text + query.value(0);
  113. text = text + " pounds ";
  114. text = text + Number(query.value(0)) / 2.2;
  115. text = text + " Kg (";
  116. q = "SELECT ";
  117. q = q + query.value(0);
  118. q = q + " / (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  119. q = q + items.currentData();
  120. q = q + ")";
  121. query.exec(q);
  122. query.next();
  123. text = text + query.value(0);
  124. text = text + " bags)";
  125. status.plainText = text;
  126. query = query.invalidate();
  127. });
  128. types['currentIndexChanged(int)'].connect(function(typeindex) {
  129. switch(typeindex) {
  130. case 0:
  131. reason.enabled = false;
  132. break;
  133. case 1:
  134. reason.enabled = true;
  135. break;
  136. }
  137. });
  138. ]]>
  139. </program>
  140. </window>