Browse Source

support arbitrary voucher type

Pi 4 months ago
parent
commit
a56aae6790
2 changed files with 5 additions and 6 deletions
  1. 3 4
      util-sqlpage/code/form-fuel.sql
  2. 2 2
      util-sqlpage/code/json/filters.json

+ 3 - 4
util-sqlpage/code/form-fuel.sql

@@ -1,16 +1,15 @@
---TODO: show barcode at top
---SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/QR.sql') AS properties;
-SET ":title" = 'Fuel Voucher';
 SET ":created" = COALESCE(:created, (SELECT created FROM code WHERE hash = :hash));
 SET ":expiry" = COALESCE(:expiry, (SELECT expiry FROM code_detail WHERE hash = :hash));
 SET ":value" = COALESCE(:value, (SELECT value FROM code_detail WHERE hash = :hash));
 SET ":store" = COALESCE(:store, json_array((SELECT store FROM code_detail WHERE hash = :hash)));
 SET ":used" = COALESCE(:used, (SELECT used FROM code_detail WHERE hash = :hash));
+SET ":type" = COALESCE(:type, json_array((SELECT type FROM code_detail WHERE hash = :hash)));
+SET ":title" = COALESCE(:type->>0, 'New')||' Voucher';
+SET ":type" = COALESCE(:type, json_array('Fuel'));
 SET ":content" = (SELECT json(content) FROM code WHERE hash = :hash);
 SET ":validate" = 'Update';
 SET ":action" = (CASE COALESCE(:action, '') WHEN '' THEN NULL ELSE :action END);
 SET ":method" = 'post';
-SET ":type" = json_array('Fuel');
 SET ":preview" = (SELECT 'data:image/svg+xml;base64,'||svg FROM code WHERE hash = :hash);
 SET ":autofill" = TRUE;
 SET ":filter_config" = '[

+ 2 - 2
util-sqlpage/code/json/filters.json

@@ -1,6 +1,6 @@
 [
-    { "name": "type[]", "label": "",
-      "type": "hidden",
+    { "name": "type[]", "label": "Type",
+      "type": "select", "dropdown": true, "create_new": true,
       "width": 2
     },
     { "name": "store[]", "label": "Store",