瀏覽代碼

Add dashboard displays for latest out of stock coffees, least available coffees, and unused coffees

Neal Wilson 7 年之前
父節點
當前提交
8c323d2e21
共有 1 個檔案被更改,包括 55 行新增0 行删除
  1. 55
    0
      config/Windows/navigation.xml

+ 55
- 0
config/Windows/navigation.xml 查看文件

@@ -477,6 +477,9 @@
477 477
             drawReminders(output, query);
478 478
             drawSchedule(output, query);
479 479
             drawLatest(output, query);
480
+            drawRecentlyOut(output, query);
481
+            drawLeastAvailable(output, query);
482
+            drawUnused(output, query);
480 483
             drawMostRoasted(output, query);
481 484
             drawLeastRoasted(output, query);
482 485
             query = query.invalidate();
@@ -719,6 +722,58 @@
719 722
                 endCell(output);
720 723
             }
721 724
         }
725
+        var drawLeastAvailable = function(output, query) {
726
+            var u = unitData();
727
+            query.prepare("SELECT name, (quantity / :conversion)::numeric(12,2) AS quantity, (SELECT out FROM coffee_history WHERE coffee_history.id = items.id) AS out FROM items WHERE quantity > 0 ORDER BY out ASC LIMIT 5");
728
+            query.bind(":conversion", u.conversion);
729
+            query.exec();
730
+            if(query.next()) {
731
+                startCell(output, TTR("navwindow", "Least Available Coffes"));
732
+                startStage(output);
733
+                output.writeStartElement("table");
734
+                do {
735
+                    output.writeStartElement("tr");
736
+                    output.writeTextElement("td", query.value(1) + u.unittext);
737
+                    output.writeTextElement("td", query.value(0));
738
+                    output.writeTextElement("td", query.value(2));
739
+                    output.writeEndElement();
740
+                } while(query.next());
741
+                output.writeEndElement();
742
+                endStage(output);
743
+                endCell(output);
744
+            }
745
+        }
746
+        var drawRecentlyOut = function(output, query) {
747
+            query.exec("SELECT (SELECT name FROM items WHERE id = item), max(time)::date AS last_transaction FROM transactions WHERE item IN (SELECT id FROM items WHERE quantity = 0) GROUP BY item ORDER BY last_transaction DESC LIMIT 5");
748
+            if(query.next()) {
749
+                startCell(output, TTR("navwindow", "Latest Out of Stock Coffees"));
750
+                startStage(output);
751
+                output.writeStartElement("table");
752
+                do {
753
+                    output.writeStartElement("tr");
754
+                    output.writeTextElement("td", query.value(1));
755
+                    output.writeTextElement("td", query.value(0));
756
+                    output.writeEndElement();
757
+                } while(query.next());
758
+                output.writeEndElement();
759
+                endStage(output);
760
+                endCell(output);
761
+            }
762
+        }
763
+        var drawUnused = function(output, query) {
764
+            query.exec("SELECT name FROM coffees WHERE id NOT IN (SELECT item FROM use) AND quantity > 0");
765
+            var c = 0;
766
+            if(query.next()) {
767
+                c += 1;
768
+                startCell(output, TTR("navwindow", "Unused Coffees"));
769
+                startStage(output);
770
+                do {
771
+                    output.writeTextElement("p", query.value(0));
772
+                } while(query.next());
773
+                endStage(output);
774
+                endCell(output, "" + c + TTR("navwindow", " unused coffees"));
775
+            }
776
+        }
722 777
         refresh();
723 778
         dashboard.scriptLinkClicked.connect(function(url) {
724 779
             if(url == "reminders") {

Loading…
取消
儲存