Browse Source

Add dialog to set opening amount (issue #1)

master
Skylar Ittner 1 year ago
parent
commit
5775599b4b
3 changed files with 26 additions and 7 deletions
  1. 1
    0
      pages.php
  2. 9
    7
      pages/registers.php
  3. 16
    0
      static/js/registers.js

+ 1
- 0
pages.php View File

@@ -64,6 +64,7 @@ define("PAGES", [
64 64
             "static/css/tables.css"
65 65
         ],
66 66
         "scripts" => [
67
+            "static/js/bsalert.js",
67 68
             "static/js/datatables.min.js",
68 69
             "static/js/registers.js"
69 70
         ],

+ 9
- 7
pages/registers.php View File

@@ -85,12 +85,7 @@ $registers = $database->select('registers', ['registerid (id)', 'registername (n
85 85
                         <?php
86 86
                     } else {
87 87
                         ?>
88
-                        <form action="action.php" method="POST" class="d-inline">
89
-                            <input type="hidden" name="action" value="opencash" />
90
-                            <input type="hidden" name="source" value="registers" />
91
-                            <input type="hidden" name="register" value="<?php echo $r['id']; ?>" />
92
-                            <button class="btn btn-success btn-sm" type="submit"><i class="fas fa-play"></i> <?php lang("open"); ?></button>
93
-                        </form>
88
+                        <button class="btn btn-success btn-sm btn-opencash" data-register="<?php echo $r['id']; ?>"><i class="fas fa-play"></i> <?php lang("open"); ?></button>
94 89
                         <?php
95 90
                     }
96 91
                     ?>
@@ -114,4 +109,11 @@ $registers = $database->select('registers', ['registerid (id)', 'registername (n
114 109
             <th data-priority="3"><i class="fas fa-fw fa-stop d-none d-md-inline"></i> <?php lang('closed'); ?></th>
115 110
         </tr>
116 111
     </tfoot>
117
-</table>
112
+</table>
113
+
114
+<form action="action.php" method="POST" class="d-none" id="opencashform">
115
+    <input type="hidden" name="action" value="opencash" />
116
+    <input type="hidden" name="source" value="registers" />
117
+    <input type="hidden" name="startamount" value="" id="opencashstart" />
118
+    <input type="hidden" name="register" value="" id="opencashregid" />
119
+</form>

+ 16
- 0
static/js/registers.js View File

@@ -31,4 +31,20 @@ var registertable = $('#registertable').DataTable({
31 31
     order: [
32 32
         [2, 'asc']
33 33
     ]
34
+});
35
+
36
+$("#registertable").on('click', '.btn-opencash', function () {
37
+    var regid = $(this).data("register");
38
+    bsprompt(
39
+            "Open Cash",
40
+            "Enter the opening amount of cash in the drawer.",
41
+            "Open Cash",
42
+            "Cancel",
43
+            "number",
44
+            function (result) {
45
+                $("#opencashform #opencashregid").val(regid);
46
+                $("#opencashform #opencashstart").val(result);
47
+                $("#opencashform").submit();
48
+            }
49
+    );
34 50
 });

Loading…
Cancel
Save