<?php
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

$registers = $database->select("registers", ['[>]cash_drawer' => ['registerid' => 'registerid']], ['registers.registerid (id)', 'registername (name)'], ['AND' => ['open[!]' => null, 'close' => null], 'ORDER' => 'registername']);
?>

<div class="row justify-content-center">
    <div class="col-12 col-sm-8 col-md-6 col-lg-4">
        <form class="card border-green" action="action.php" method="POST">
            <h3 class="card-header text-green">
                <?php lang("point of sale"); ?>
            </h3>
            <div class="card-body">
                <h5 class="card-title"><?php lang("choose register"); ?></h5>
                <?php
                if (count($registers) > 0) {
                    ?>
                    <div class="list-group">
                        <?php
                        foreach ($registers as $r) {
                            ?>
                            <button class="list-group-item" name="register" value="<?php echo $r['id']; ?>">
                                <?php echo $r['name']; ?>
                            </button>
                            <?php
                        }
                        ?>
                    </div>
                    <?php
                } else {
                    ?>
                <div class="alert alert-info">
                    <?php lang("no open registers"); ?>
                </div>
                <?php
                }
                ?>
            </div>
            <input type="hidden" name="action" value="set_register" />
            <input type="hidden" name="source" value="pos" />
        </form>
    </div>
</div>