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.

batchdetailsnew.xml 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <window id="batchDetails">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <button type="push" id="target" name="Load profile as target" />
  5. <stretch />
  6. <label>Search:</label>
  7. <line id="search" />
  8. </layout>
  9. <tabbar id="tabs" />
  10. <layout type="stack" id="pages">
  11. <page>
  12. <layout type="vertical">
  13. <webview id="view" />
  14. </layout>
  15. </page>
  16. <page>
  17. <layout type="vertical">
  18. <splitter type="horizontal" id="logsplit">
  19. <measurementtable id="log">
  20. <column>Time</column>
  21. <column>Bean</column>
  22. <column>Air</column>
  23. <column>Note</column>
  24. </measurementtable>
  25. <graph id="graph" />
  26. </splitter>
  27. </layout>
  28. </page>
  29. <page>
  30. <layout type="vertical">
  31. <layout type="horizontal">
  32. <label>Roasted Weight: </label>
  33. <line id="roasted" validator="numeric" />
  34. <line id="roastunit" writable="false" />
  35. <stretch />
  36. </layout>
  37. <label>Degree of Roast</label>
  38. <layout type="horizontal">
  39. <label>Whole Bean:</label>
  40. <roastcoloredit id="wholecolor" />
  41. <stretch />
  42. </layout>
  43. <label id="wholespec">-</label>
  44. <layout type="horizontal">
  45. <label>Ground:</label>
  46. <roastcoloredit id="groundcolor" />
  47. <stretch />
  48. </layout>
  49. <label id="groundspec">-</label>
  50. <button type="check" name="Approved" id="approval" />
  51. <layout type="horizontal">
  52. <label>Annotation</label>
  53. <textarea id="annotation" />
  54. </layout>
  55. <button type="push" id="submit" name="Save" />
  56. <stretch />
  57. </layout>
  58. </page>
  59. <page>
  60. <layout type="vertical">
  61. <webview id="batchTag" />
  62. <layout type="horizontal">
  63. <printerselector id="printerlist" />
  64. <button name="Print" id="printbutton" type="push" />
  65. </layout>
  66. </layout>
  67. </page>
  68. </layout>
  69. </layout>
  70. <menu name="File">
  71. <item id="save" shortcut="Ctrl+S">Save Profile...</item>
  72. <item id="print" shortcut="Ctrl+P">Print Report...</item>
  73. </menu>
  74. <menu name="Log">
  75. <item id="showC">Display Celsius</item>
  76. <item id="showF">Display Fahrenheit</item>
  77. <separator />
  78. <item id="ms">Millisecond View</item>
  79. <item id="1s">1 Second View</item>
  80. <item id="5s">5 Second View</item>
  81. <item id="10s">10 Second View</item>
  82. <item id="15s">15 Second View</item>
  83. <item id="30s">30 Second View</item>
  84. <item id="1m">1 Minute View</item>
  85. </menu>
  86. <program>
  87. <![CDATA[
  88. var window = this;
  89. window.windowTitle = TTR("batchDetails", "Typica - Batch Details");
  90. var tabs = findChildObject(this, 'tabs');
  91. tabs.addTab(TTR("batchDetails", "Report"));
  92. tabs.addTab(TTR("batchDetails", "Profile"));
  93. tabs.addTab(TTR("batchDetails", "Edit"));
  94. tabs.addTab(TTR("batchDetails", "Batch Tag"));
  95. var pages = findChildObject(this, 'pages');
  96. tabs.currentChanged.connect(function(index) {
  97. pages.setCurrentIndex(index);
  98. });
  99. var log = findChildObject(this, 'log');
  100. var graph = findChildObject(this, 'graph');
  101. var showC = findChildObject(this, 'showC');
  102. showC.triggered.connect(function() {
  103. log.setDisplayUnits(Units.Celsius);
  104. graph.showC();
  105. });
  106. var showF = findChildObject(this, 'showF');
  107. showF.triggered.connect(function() {
  108. log.setDisplayUnits(Units.Fahrenheit);
  109. graph.showF();
  110. });
  111. var v1 = findChildObject(this, 'ms');
  112. v1.triggered.connect(log.LOD_ms);
  113. var v2 = findChildObject(this, '1s');
  114. v2.triggered.connect(log.LOD_1s);
  115. var v3 = findChildObject(this, '5s');
  116. v3.triggered.connect(log.LOD_5s);
  117. var v4 = findChildObject(this, '10s');
  118. v4.triggered.connect(log.LOD_10s);
  119. var v5 = findChildObject(this, '15s');
  120. v5.triggered.connect(log.LOD_15s);
  121. var v6 = findChildObject(this, '30s');
  122. v6.triggered.connect(log.LOD_30s);
  123. var v7 = findChildObject(this, '1m');
  124. v7.triggered.connect(log.LOD_1m);
  125. var splitter = findChildObject(this, 'logsplit');
  126. splitter.restoreState("script/offlineViewSplitter");
  127. window.saveTemperatureColumns = new Array();
  128. window.saveAnnotationColumns = new Array();
  129. this.aboutToClose.connect(function() {
  130. splitter.saveState("script/batchdetails/profileSplitter");
  131. });
  132. var unit = QSettings.value("script/history_unit", 1);
  133. var conversion = 1;
  134. if(unit == 0)
  135. {
  136. conversion = 2.2;
  137. }
  138. var unitText = (unit == 0 ? TTR("batchDetails", "Kg") :
  139. TTR("batchDetails", "Lb"));
  140. dataView = findChildObject(this, 'view');
  141. var printMenu = findChildObject(this, 'print');
  142. printMenu.triggered.connect(function() {
  143. dataView.print();
  144. });
  145. var fileID;
  146. var target = findChildObject(this, 'target');
  147. if(typeof(Windows.loggingWindow) == "undefined") {
  148. target.enabled = false;
  149. }
  150. var tableReference;
  151. var rowReference;
  152. var batchTime;
  153. var machine;
  154. var approval;
  155. var annotation;
  156. var roastWeight;
  157. target.clicked.connect(function() {
  158. var query = new QSqlQuery;
  159. query.prepare("SELECT file, name FROM files WHERE id = :id");
  160. query.bind(":id", Number(fileID));
  161. query.exec();
  162. query.next();
  163. var buffer = new QBuffer(query.value(0));
  164. var pname = query.value(1);
  165. query = query.invalidate();
  166. Windows.loggingWindow.loadPlan(buffer, pname);
  167. });
  168. var approvalButton = findChildObject(this, 'approval');
  169. var annotationField = findChildObject(this, 'annotation');
  170. var roastedEdit = findChildObject(this, 'roasted');
  171. var unitEdit = findChildObject(this, 'roastunit');
  172. var wholecolor = findChildObject(this, 'wholecolor');
  173. var groundcolor = findChildObject(this, 'groundcolor');
  174. window.loadBatch = function(mref, tref) {
  175. machine = mref;
  176. batchTime = tref;
  177. var query = new QSqlQuery();
  178. var q = "WITH names AS ( WITH greens AS ( SELECT unnest(unroasted_id) AS gitem, machine, time FROM roasting_log WHERE machine = :machine AND time = :time) SELECT array_agg((SELECT name FROM items WHERE id = greens.gitem) || ' (' || gitem || ')') AS names, max(greens.machine) AS machine, max(greens.time) AS time FROM greens LIMIT 1) SELECT (SELECT name FROM items WHERE id = roasted_id), duration, names, unroasted_quantity, (unroasted_total_quantity/:c1)::numeric(12,3), (roasted_quantity/:c2)::numeric(12,3), approval, files, annotation, (SELECT file FROM files WHERE id = files[1]) AS file, additional_data, roasted_id FROM names, roasting_log WHERE roasting_log.machine = names.machine AND roasting_log.time = names.time";
  179. query.prepare(q);
  180. query.bind(":machine", mref);
  181. query.bind(":time", tref);
  182. query.bind(":c1", conversion);
  183. query.bind(":c2", conversion);
  184. query.exec();
  185. query.next();
  186. var buffer = new QBuffer;
  187. buffer.open(3);
  188. var output = new XmlWriter(buffer);
  189. output.writeStartDocument("1.0");
  190. 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">');
  191. output.writeStartElement("html");
  192. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  193. output.writeStartElement("head");
  194. output.writeTextElement("title", "Batch Details");
  195. output.writeEndElement();
  196. output.writeStartElement("body");
  197. output.writeStartElement("div");
  198. output.writeAttribute("style", "float: left; padding-right: 10px");
  199. output.writeStartElement("p");
  200. output.writeTextElement("strong", TTR("batchDetails", "Roasted Coffee: "));
  201. output.writeTextElement("span", query.value(0));
  202. output.writeEndElement();
  203. output.writeEndElement();
  204. output.writeStartElement("div");
  205. output.writeAttribute("style", "float: left");
  206. output.writeStartElement("p");
  207. output.writeTextElement("strong", TTR("batchDetails", "Roasted At: "));
  208. output.writeTextElement("span", batchTime);
  209. output.writeEndElement();
  210. output.writeStartElement("p");
  211. output.writeTextElement("strong", TTR("batchDetails", "Batch Duration: "));
  212. output.writeTextElement("span", query.value(1));
  213. output.writeEndElement();
  214. output.writeEndElement();
  215. output.writeStartElement("div");
  216. output.writeAttribute("style", "clear: both");
  217. output.writeEndElement();
  218. output.writeStartElement("table");
  219. output.writeStartElement("thead");
  220. output.writeStartElement("tr");
  221. output.writeTextElement("th", TTR("batchDetails", "Green Coffee"));
  222. output.writeTextElement("th", TTR("batchDetails", "Weight") + "(" + unitText + ")");
  223. output.writeEndElement();
  224. output.writeEndElement();
  225. output.writeStartElement("tbody");
  226. var items = sqlToArray(query.value(2));
  227. var quantities = sqlToArray(query.value(3));
  228. for(var i = 0; i < items.length; i++) {
  229. output.writeStartElement("tr");
  230. output.writeTextElement("td", items[i]);
  231. output.writeStartElement("td");
  232. output.writeAttribute("align", "center");
  233. output.writeCharacters(Number(quantities[i]/conversion).toFixed(3));
  234. output.writeEndElement();
  235. output.writeEndElement();
  236. }
  237. output.writeEndElement();
  238. output.writeStartElement("tfoot");
  239. output.writeStartElement("tr");
  240. output.writeStartElement("td");
  241. output.writeAttribute("align", "right");
  242. output.writeTextElement("strong", TTR("batchDetails", "Green Total:"));
  243. output.writeEndElement();
  244. output.writeStartElement("td");
  245. output.writeAttribute("align", "center");
  246. output.writeCharacters(query.value(4));
  247. output.writeEndElement();
  248. output.writeEndElement();
  249. output.writeStartElement("tr");
  250. output.writeStartElement("td");
  251. output.writeAttribute("align", "right");
  252. output.writeTextElement("strong", TTR("batchDetails", "Roasted Weight:"));
  253. output.writeEndElement();
  254. output.writeStartElement("td");
  255. output.writeAttribute("align", "center");
  256. output.writeCharacters(query.value(5));
  257. output.writeEndElement();
  258. output.writeEndElement();
  259. output.writeStartElement("tr");
  260. output.writeStartElement("td");
  261. output.writeAttribute("align", "right");
  262. output.writeTextElement("strong", TTR("batchDetails", "Weight Loss:"));
  263. output.writeEndElement();
  264. output.writeStartElement("td");
  265. output.writeAttribute("align", "center");
  266. if(Number(query.value(4)) > 0) {
  267. output.writeCharacters(Number(((Number(query.value(4)) - Number(query.value(5)))/Number(query.value(4))) * 100).toFixed(2));
  268. output.writeCharacters("%");
  269. } else {
  270. output.writeCharacters("unknown");
  271. }
  272. output.writeEndElement();
  273. output.writeEndElement();
  274. output.writeEndElement();
  275. output.writeEndElement();
  276. if(query.value(10).length > 0) {
  277. var extradata = JSON.parse(query.value(10));
  278. if(extradata.color) {
  279. output.writeStartElement("p");
  280. output.writeTextElement("strong", TTR("batchDetails", "Degree of Roast"));
  281. output.writeEndElement();
  282. if(extradata.color.whole) {
  283. wholecolor.value = extradata.color.whole;
  284. output.writeStartElement("p");
  285. output.writeTextElement("strong", TTR("batchDetails", "Whole Bean: "));
  286. output.writeTextElement("span", extradata.color.whole);
  287. output.writeEndElement();
  288. } else {
  289. wholecolor.value = "";
  290. }
  291. if(extradata.color.ground) {
  292. groundcolor.value = extradata.color.ground;
  293. output.writeStartElement("p");
  294. output.writeTextElement("strong", TTR("batchDetails", "Ground: "));
  295. output.writeTextElement("span", extradata.color.ground);
  296. output.writeEndElement();
  297. } else {
  298. groundcolor.value = "";
  299. }
  300. } else {
  301. wholecolor.value = "";
  302. groundcolor.value = "";
  303. }
  304. } else {
  305. wholecolor.value = "";
  306. groundcolor.value = "";
  307. }
  308. output.writeStartElement("p");
  309. output.writeTextElement("strong", TTR("batchDetails", "Approved: "));
  310. output.writeCharacters(query.value(6));
  311. output.writeEndElement();
  312. output.writeStartElement("p");
  313. output.writeTextElement("strong", TTR("batchDetails", "Files: "));
  314. output.writeCharacters(query.value(7));
  315. output.writeEndElement();
  316. output.writeStartElement("p");
  317. output.writeTextElement("strong", TTR("batchDetails", "Annotations:"));
  318. var files = sqlToArray(query.value(7));
  319. var annotations = annotationFromRecord(files[0]);
  320. fileID = files[0];
  321. var buffer2 = new QBuffer("<points>"+annotations+"</points>");
  322. buffer2.open(1);
  323. var colQuery = new XQuery;
  324. colQuery.bind("profile", buffer2);
  325. colQuery.setQuery('for $i in doc($profile)//tuple[1]/temperature/@series return (string($i), ";")');
  326. var result = colQuery.exec();
  327. buffer2.close();
  328. var seriesHeaders = new Array();
  329. seriesHeaders.push(TTR("batchDetails", "Time"));
  330. var records = result.split(";");
  331. for(var i = 0; i < records.length - 1; i++) {
  332. seriesHeaders.push(records[i].replace(/^\s+|\s+$/g,""));
  333. }
  334. seriesHeaders.push(TTR("batchDetails", "Note"));
  335. output.writeStartElement("table");
  336. output.writeStartElement("thead");
  337. output.writeStartElement("tr");
  338. for(var i = 0; i < seriesHeaders.length; i++) {
  339. output.writeTextElement("th", seriesHeaders[i]);
  340. }
  341. output.writeEndElement();
  342. output.writeEndElement();
  343. buffer2.open(1);
  344. var rq = 'for $t in doc($profile) //tuple return (string($t/time), ";", ';
  345. for(var i = 0; i < seriesHeaders.length - 2; i++) {
  346. rq += 'string($t/temperature[' + Number(i+1) + ']), ";", ';
  347. }
  348. rq += 'string($t/annotation), "~")';
  349. colQuery.setQuery(rq);
  350. var annotationData = colQuery.exec();
  351. colQuery = colQuery.invalidate();
  352. buffer2.close();
  353. output.writeStartElement("tbody");
  354. var annotationRecords = annotationData.split("~");
  355. for(var i = 0; i < annotationRecords.length - 1; i++) {
  356. output.writeStartElement("tr");
  357. var annotationRow = annotationRecords[i].split(";");
  358. for(var j = 0; j < annotationRow.length; j++) {
  359. output.writeStartElement("td");
  360. output.writeAttribute("style", "border-left: 1px solid #000000");
  361. if(j > 0) {
  362. output.writeAttribute("align", "center");
  363. }
  364. if(j > 0 && j < annotationRow.length - 1) {
  365. output.writeCharacters(Number(annotationRow[j].replace(/^\s+|\s+$/g,"")).toFixed(2));
  366. } else {
  367. output.writeCharacters(annotationRow[j].replace(/^\s+|\s+$/g,""));
  368. }
  369. output.writeEndElement();
  370. }
  371. output.writeEndElement();
  372. }
  373. output.writeEndElement();
  374. output.writeEndElement();
  375. output.writeCharacters(query.value(8));
  376. output.writeEndElement();
  377. output.writeEndElement();
  378. output.writeEndElement();
  379. output.writeEndDocument();
  380. dataView.setContent(buffer);
  381. buffer.close();
  382. log.clear();
  383. graph.clear();
  384. var buffer3 = new QBuffer(query.value(9));
  385. var input = new XMLInput(buffer3, 1);
  386. input.newTemperatureColumn.connect(log.setHeaderData);
  387. input.newAnnotationColumn.connect(log.setHeaderData);
  388. var lc;
  389. input.lastColumn.connect(function(c) {
  390. lc = c;
  391. if(c < 3) {
  392. log.setHeaderData(3, "");
  393. }
  394. });
  395. input.measure.connect(graph.newMeasurement);
  396. input.measure.connect(log.newMeasurement);
  397. input.annotation.connect(function(note,tcol,ncol) {
  398. for(var i = tcol; i < ncol; i++) {
  399. log.newAnnotation(note, i, ncol);
  400. }
  401. });
  402. graph.updatesEnabled = false;
  403. log.updatesEnabled = false;
  404. input.input();
  405. log.updatesEnabled = true;
  406. graph.updatesEnabled = true;
  407. log.newAnnotation("End", 1, lc);
  408. if(query.value(6) == "true") {
  409. approvalButton.checked = true;
  410. }
  411. annotationField.plainText = query.value(8);
  412. unitEdit.text = unitText;
  413. roastedEdit.text = query.value(5);
  414. drawTag(query.value(11), query.value(0));
  415. query = query.invalidate();
  416. }
  417. var saveMenu = findChildObject(this, 'save');
  418. saveMenu.triggered.connect(function() {
  419. var filename = QFileDialog.getSaveFileName(window, TTR("batchDetails", "Save Log As..."), QSettings.value("script/lastDir", "") + "/");
  420. if(filename != "") {
  421. saveFileFromDatabase(fileID, filename);
  422. }
  423. });
  424. var submit = findChildObject(this, 'submit');
  425. submit.clicked.connect(function() {
  426. var query = new QSqlQuery;
  427. query.prepare("UPDATE roasting_log SET roasted_quantity = :roasted, approval = :approval, annotation = :annotation, additional_data = :extradata WHERE time = :time AND machine = :machine");
  428. query.bind(":approval", approvalButton.checked);
  429. query.bind(":annotation", annotationField.plainText);
  430. query.bind(":roasted", Number(Number(roastedEdit.text)*conversion));
  431. var extradata = new Object;
  432. var colordata = new Object;
  433. if(wholecolor.value.length > 0) {
  434. colordata.whole = wholecolor.value;
  435. }
  436. if(groundcolor.value.length > 0) {
  437. colordata.ground = groundcolor.value;
  438. }
  439. if(colordata.whole || colordata.ground) {
  440. extradata.color = colordata;
  441. }
  442. query.bind(":extradata", JSON.stringify(extradata));
  443. query.bind(":time", batchTime);
  444. query.bind(":machine", Number(machine));
  445. query.exec();
  446. query = query.invalidate();
  447. window.loadBatch(machine, batchTime);
  448. displayInfo(TTR("batchDetails", "Batch Data Saved"),
  449. TTR("roastspec", "New batch details saved"));
  450. });
  451. var batchTag = findChildObject(this, 'batchTag');
  452. var printers = findChildObject(this, 'printerlist');
  453. printers.currentIndex = printers.findText(QSettings.value("script/batchtagprinter"));
  454. printers['currentIndexChanged(int)'].connect(function() {
  455. QSettings.setValue("script/batchtagprinter", printers.currentText);
  456. });
  457. var printbutton = findChildObject(this, 'printbutton');
  458. printbutton.clicked.connect(function() {
  459. batchTag.print(printers.currentText);
  460. });
  461. function drawTag(item, name) {
  462. var buffer = new QBuffer;
  463. buffer.open(3);
  464. var output = new XmlWriter(buffer);
  465. output.writeStartDocument("1.0");
  466. 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">');
  467. output.writeStartElement("html");
  468. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  469. output.writeStartElement("head");
  470. var styleFile = new QFile(QSettings.value("config") + "/Scripts/batchtag.css");
  471. styleFile.open(1);
  472. output.writeTextElement("style", styleFile.readToString());
  473. styleFile.close();
  474. styleFile = new QFile(QSettings.value("config") + "/Scripts/barcode.css");
  475. styleFile.open(1);
  476. output.writeTextElement("style", styleFile.readToString());
  477. styleFile.close();
  478. output.writeStartElement("script");
  479. scriptFile = new QFile(QSettings.value("config") + "/Scripts/qrcode.js");
  480. scriptFile.open(1);
  481. output.writeCDATA(scriptFile.readToString());
  482. scriptFile.close();
  483. output.writeEndElement();
  484. output.writeStartElement("script");
  485. scriptFile = new QFile(QSettings.value("config") + "/Scripts/barcode.js");
  486. scriptFile.open(1);
  487. output.writeCDATA(scriptFile.readToString());
  488. scriptFile.close();
  489. output.writeEndElement();
  490. output.writeEndElement();
  491. output.writeStartElement("body");
  492. output.writeStartElement("h1");
  493. output.writeCharacters(name + " (" + item + ")");
  494. output.writeEndElement();
  495. output.writeTextElement("span", "Roasted at: " + batchTime);
  496. output.writeTextElement("span", "On machine: " + machine);
  497. output.writeTextElement("span", "Batch file: " + fileID);
  498. output.writeStartElement("div");
  499. output.writeAttribute("id", "barcode");
  500. output.writeAttribute("class", "barcode128h");
  501. output.writeAttribute("align", "center");
  502. output.writeEndElement();
  503. output.writeStartElement("script");
  504. var c128data = 'var strBarcodeHTML = code128("';
  505. c128data += fileID;
  506. c128data += '", "C");'
  507. c128data += 'document.getElementById("barcode").innerHTML = strBarcodeHTML;';
  508. output.writeCDATA(c128data);
  509. output.writeEndElement();
  510. output.writeStartElement("div");
  511. output.writeAttribute("id", "container");
  512. output.writeEndElement();
  513. output.writeStartElement("script");
  514. var tag = {g: "Typica", m: Number(machine), v: 1};
  515. tag.t = batchTime;
  516. tag.f = Number(fileID);
  517. var scriptData = 'var width = document.getElementById("container").offsetWidth;';
  518. scriptData += 'var qrcode = new QRCode({content: \'';
  519. scriptData += JSON.stringify(tag);
  520. scriptData += '\', width: width, height: width});';
  521. scriptData += 'var svg = qrcode.svg();';
  522. scriptData += 'document.getElementById("container").innerHTML = svg;';
  523. output.writeCDATA(scriptData);
  524. output.writeEndElement();
  525. output.writeEndElement();
  526. output.writeEndElement();
  527. output.writeEndDocument();
  528. batchTag.setContent(buffer);
  529. buffer.close();
  530. };
  531. var search = findChildObject(this, 'search');
  532. search.returnPressed.connect(function() {
  533. if(search.text.length == 0) {
  534. return;
  535. }
  536. if(Number(search.text)) {
  537. if(search.text[0] == '0' && search.text[1] == '0') {
  538. var query = new QSqlQuery();
  539. query.prepare("SELECT machine, time FROM scheduled_roasts WHERE id = :id");
  540. query.bind(":id", Number(search.text));
  541. query.exec();
  542. if(query.next()) {
  543. window.loadBatch(query.value(0), query.value(1));
  544. }
  545. query = query.invalidate();
  546. } else {
  547. var query = new QSqlQuery();
  548. query.prepare("SELECT machine, time FROM roasting_log WHERE files[1] = :file");
  549. query.bind(":file", Number(search.text));
  550. query.exec();
  551. if(query.next()) {
  552. window.loadBatch(query.value(0), query.value(1));
  553. }
  554. query = query.invalidate();
  555. }
  556. } else {
  557. var tag = JSON.parse(search.text);
  558. if(tag.m != undefined && tag.t != undefined) {
  559. window.loadBatch(tag.m, tag.t);
  560. }
  561. }
  562. search.text = "";
  563. });
  564. ]]>
  565. </program>
  566. </window>