Browse Source

Automatically show picker grid conditionally based on number of items

master
Skylar Ittner 1 year ago
parent
commit
9ec33b06fe
3 changed files with 14 additions and 2 deletions
  1. 4
    1
      pages/pos.php
  2. 3
    0
      settings.template.php
  3. 7
    1
      static/js/pos_gridview.js

+ 4
- 1
pages/pos.php View File

@@ -13,7 +13,7 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$database->has('
require_once __DIR__ . "/../lib/chooseregister.php";
} else {
$register = $database->get('registers', ['registerid (id)', 'registername (name)'], ['registerid' => $_SESSION['register']]);
$griditems = $binstack->select('items', ['itemid (id)', 'name', 'price', 'code1', 'code2'], ['AND' => ['price[!]' => null, 'price[!]' => 0]]);
$showgridbydefault = $binstack->count('items', ['AND' => ['price[!]' => null, 'price[!]' => 0]]) <= GRID_BY_DEFAULT_MAX_ITEMS;
?>
<div class="modal fade" tabindex="-1" role="dialog" id="receiptmodal">
<div class="modal-dialog" role="document">
@@ -156,6 +156,9 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$database->has('
</div>
</div>
</div>
<script nonce="<?php echo $SECURE_NONCE; ?>">
var showgridbydefault = <?php echo $showgridbydefault === true ? "true" : "false" ?>;
</script>
<?php
}
?>

+ 3
- 0
settings.template.php View File

@@ -29,6 +29,9 @@ define("BINSTACK_DB_CHARSET", "utf8");
// Name of the app.
define("SITE_TITLE", "NickelBox");

// If there are this many or fewer items,
// load the POS grid view automatically
define("GRID_BY_DEFAULT_MAX_ITEMS", 20);

// URL of the AccountHub API endpoint
define("PORTAL_API", "http://localhost/accounthub/api.php");

+ 7
- 1
static/js/pos_gridview.js View File

@@ -50,4 +50,10 @@ $("#gridviewbtn").click(function () {
$("#gridview").removeClass("d-none");
loadGridView();
}
});
});

if (showgridbydefault) {
$("#gridview").addClass("d-flex");
$("#gridview").removeClass("d-none");
loadGridView();
}

Loading…
Cancel
Save