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.

roastmanager.xml 4.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <window id="newroasted">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>New Roasted Coffee:</label>
  5. <line id="name" />
  6. <button id="ok" type="push" name="Add New Coffee" />
  7. </layout>
  8. <layout type="horizontal">
  9. <layout type="vertical">
  10. <label>Current Items:</label>
  11. <sqldrop data="0" display="1" showdata="false" id="currentitems">
  12. <query>SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name</query>
  13. </sqldrop>
  14. <button id="remove" type="push" name="Remove Item" />
  15. </layout>
  16. <layout type="vertical">
  17. <label>Discontinued Items:</label>
  18. <sqldrop data="0" display="1" showdata="false" id="pastitems">
  19. <query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id NOT IN (SELECT item FROM current_items) ORDER BY name</query>
  20. </sqldrop>
  21. <button id="restore" type="push" name="Restore Item" />
  22. </layout>
  23. </layout>
  24. </layout>
  25. <program>
  26. <![CDATA[
  27. this.displayStatus("Ready.");
  28. var itemname = findChildObject(this, 'name');
  29. var newItemButton = findChildObject(this, 'ok');
  30. var window = this;
  31. var drop1 = findChildObject(this, 'currentitems');
  32. var drop2 = findChildObject(this, 'pastitems');
  33. var removeButton = findChildObject(this, 'remove');
  34. var restoreButton = findChildObject(this, 'restore');
  35. removeButton.clicked.connect(function() {
  36. var q = "DELETE FROM current_items WHERE item = :id";
  37. query = new QSqlQuery();
  38. query.prepare(q);
  39. query.bind(":id", drop1.currentData());
  40. query.exec();
  41. query = query.invalidate();
  42. drop1.clear();
  43. drop2.clear();
  44. drop1.addSqlOptions("SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name");
  45. drop2.addSqlOptions("SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id NOT IN (SELECT item FROM current_items) ORDER BY name");
  46. window.displayStatus("Item removed.");
  47. });
  48. restoreButton.clicked.connect(function() {
  49. var q = "INSERT INTO current_items (item) VALUES (:id)";
  50. query = new QSqlQuery();
  51. query.prepare(q);
  52. query.bind(":id", drop2.currentData());
  53. query.exec();
  54. query = query.invalidate();
  55. drop1.clear();
  56. drop2.clear();
  57. drop1.addSqlOptions("SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name");
  58. drop2.addSqlOptions("SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id NOT IN (SELECT item FROM current_items) ORDER BY name");
  59. window.displayStatus("Item restored.");
  60. });
  61. newItemButton.clicked.connect(function() {
  62. var q = "INSERT INTO items (id, name, reference, unit, quantity, category) VALUES (default, :name, NULL, 'lb', 0, 'Coffee: Roasted') RETURNING id";
  63. query = new QSqlQuery();
  64. query.prepare(q);
  65. query.bind(":name", itemname.text);
  66. query.exec();
  67. query.next();
  68. var i = query.value(0);
  69. q = "INSERT INTO current_items (item) VALUES(:id)";
  70. query.prepare(q);
  71. query.bind(":id", i);
  72. query.exec();
  73. query = query.invalidate();
  74. itemname.text = "";
  75. drop1.clear();
  76. drop2.clear();
  77. drop1.addSqlOptions("SELECT id, name FROM items WHERE id IN (SELECT item FROM current_items) ORDER BY name");
  78. drop2.addSqlOptions("SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id NOT IN (SELECT item FROM current_items) ORDER BY name");
  79. window.displayStatus("Item added.");
  80. });
  81. ]]>
  82. </program>
  83. </window>