Typica is a free program for professional coffee roasters. https://typica.us
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

greensales.xml 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <window id="greensales">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Date:</label>
  5. <calendar time="true" id="date" />
  6. <label>Customer:</label>
  7. <line id="customer" />
  8. <label>Weight Unit:</label>
  9. <sqldrop data="0" display="0" showdata="false" editable="false" id="units" />
  10. </layout>
  11. <sqltablearray columns="2" id="coffees">
  12. <column name="Coffee" delegate="sql" showdata="true" null="false" data="0" display="1">
  13. <![CDATA[
  14. SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name
  15. ]]>
  16. </column>
  17. <column name="Weight" delegate="numeric" />
  18. </sqltablearray>
  19. <button name="Submit" id="submit" type="push" />
  20. </layout>
  21. <program>
  22. <![CDATA[
  23. var window = this;
  24. this.windowTitle = TTR("greensales", "Typica - Enter Green Coffee Sales");
  25. var unitBox = findChildObject(this, 'units');
  26. unitBox.addItem("g");
  27. unitBox.addItem("Kg");
  28. unitBox.addItem("oz");
  29. unitBox.addItem("Lb");
  30. unitBox.currentIndex = (QSettings.value("script/greensales_unit", unitBox.findText("Lb")));
  31. unitBox['currentIndexChanged(int)'].connect(function() {
  32. QSettings.setValue("script/greensales_unit", unitBox.currentIndex);
  33. });
  34. var convertToPounds = function(w, u) {
  35. switch(u)
  36. {
  37. case "g":
  38. return w * 0.0022;
  39. case "oz":
  40. return w * 0.0625;
  41. case "Kg":
  42. return w * 2.2;
  43. }
  44. return w;
  45. };
  46. var dateField = findChildObject(this, 'date');
  47. var customerField = findChildObject(this, 'customer');
  48. var items = findChildObject(this, 'coffees');
  49. var model = items.model();
  50. model.dataChanged.connect(function() {
  51. items.resizeColumnToContents(0);
  52. });
  53. var submit = findChildObject(this, 'submit');
  54. submit.clicked.connect(function() {
  55. var query = new QSqlQuery();
  56. query.prepare("INSERT INTO sale (time, item, quantity, customer, person) VALUES(:time, :item, :quantity, :customer, :user)");
  57. query.bind(":time", dateField.text);
  58. if(customerField.text == "") {
  59. query.bind(":customer", null);
  60. }
  61. else {
  62. query.bind(":customer", customerField.text);
  63. }
  64. var coffeesArray = sqlToArray(items.columnArray(0, 32));
  65. query.bind(":user", Application.currentTypicaUser());
  66. if(coffeesArray.length > 0)
  67. {
  68. for(var i = 0; i < coffeesArray.length; i++)
  69. {
  70. if(items.data(i, 0, 32).value == '')
  71. {
  72. continue;
  73. }
  74. if(items.data(i, 1, 0).value == '')
  75. {
  76. continue;
  77. }
  78. query.bind(":item", items.data(i, 0, 32).value);
  79. query.bind(":quantity", convertToPounds(items.data(i, 1, 0).value, unitBox.currentText));
  80. query.exec();
  81. }
  82. }
  83. query = query.invalidate();
  84. window.close();
  85. });
  86. ]]>
  87. </program>
  88. </window>