<!DOCTYPE html>
<html lang="en" dir="ltr" id="main_html">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8" />
        <title id="title"></title>
        <!-- Material Icons -->
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
        <!-- Material Symbols - Outlined Set -->
        <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet" />
        <!-- Material Symbols - Rounded Set -->
        <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded" rel="stylesheet" />
        <!-- Material Symbols - Sharp Set -->
        <link rel="stylesheet" href="{{ url_for('static', filename='css/uikit.min.css') }}"/>
        <link rel="stylesheet" href="{{ url_for('static', filename='css/pantry.css') }}"/>

        <link id="dark-mode" rel="stylesheet" href="{{ url_for('static', filename='css/dark-mode.css') }}" disabled/>



    </head>
    <style>
        .custom_row:hover{
            background-color: rgb(230, 230, 230) !important;
            cursor: pointer;
        }
    </style>
    <body>
        <div uk-sticky="sel-target: .uk-navbar-container; cls-active: uk-navbar-sticky">
            <!-- to color the navbar i have to stlye this element the nav element -->
            <nav id="navbar" class="uk-navbar-container">
                <div class="uk-container uk-container-expand">
                    <div uk-navbar="dropbar: true">
                        <div id="offcanvas-slide" uk-offcanvas="mode: slide; overlay: true">
                            <div class="uk-offcanvas-bar uk-flex uk-flex-column">
                                <ul class="uk-nav uk-nav-secondary">  
                                    <img class="uk-align-center uk-border-circle" data-src="{{ url_for('static', filename='pictures/logo.jpg') }}" style="width: 150px; height: auto;" uk-img />
                                    <li class="uk-nav-header">Apps</li>
                                    <li><a href="/shopping-lists">Shopping Lists</a></li>
                                    <li><a href="/recipes">Recipes</a></li>
                                    <li class="uk-nav-header">Logistics</li>
                                    <li><a href="/items">Items</a></li>
                                    <li>
                                        <a href="/transaction">
                                            <div class="uk-active">Add Transaction<div class="uk-nav-subtitle" disabled>You are adding transactions...</div>
                                        </div></a>
                                    </li>
                                    <li><a href="/workshop">Workshop</a></li>
                                    <li><a href="/receipts">Receipts</a></li>
                                    <li class="uk-nav-header">System Management</li>
                                    <li><a><div>{{current_site}}<div class="uk-nav-subtitle">This is the current site you are viewing...</div></div></a>
                                        <div uk-dropdown="mode: click">
                                            <ul class="uk-nav uk-dropdown-nav">
                                                {% for site in sites %}
                                                {% if site == current_site  %}
                                                <li><a class="uk-disabled" href="#">{{site}}</a></li>
                                                {% else %}
                                                <li><a onclick="changeSite('{{site}}')">{{site}}</a></li>
                                                {% endif %}
                                                {% endfor %}
                                            </ul>
                                        </div>
                                    </li>
                                    {% if system_admin %}
                                    <li><a href="/admin">Administration</a></li>
                                    {% endif %}
                                    <li><a href="" class="">{{username}}</a></li>
                                </ul>
                                <button class="uk-button uk-margin-small uk-position-top-right" uk-icon="icon: close" href=""></button>
                            </div>
                        </div>
                        <div class="uk-navbar-left uk-margin-small">
                            <a href="#offcanvas-slide" class="uk-button uk-button-default uk-button-small" uk-icon="icon: menu" uk-toggle> Menu</a>
                        </div>
                        <div class="uk-navbar-center uk-margin-small uk-visible@s">
                            <ul class="uk-breadcrumb">
                                <li style="cursor: default;"><span><strong>{{current_site}}</strong></span>
                                    <div uk-dropdown="mode: hover">
                                        <ul class="uk-nav uk-dropdown-nav">
                                            {% for site in sites %}
                                            {% if site == current_site  %}
                                            <li><a class="uk-disabled" href="#">{{site}}</a></li>
                                            {% else %}
                                            <li><a onclick="changeSite('{{site}}')">{{site}}</a></li>
                                            {% endif %}
                                            {% endfor %}
                                        </ul>
                                    </div>
                                </li>
                                <li style="cursor: default; user-select: none;"><span>Logistics</span></li>
                                <li><a href="/items">Items</a></li>
                                <li class="uk-disabled"><span>Add Transaction</span></li>
                            </ul>
                        </div>
                        <div class="uk-navbar-right">
                            <div>
                                <a onclick="toggleDarkMode()" class="uk-button uk-button-small"><span id="modeToggle" class="uk-flex material-symbols-outlined">dark_mode</span></a>
                            </div>
                            <div>
                                <a href="" class="" uk-icon="icon: user" uk-toggle>{{username}}</a>
                            </div>
                        </div>
                    </div>
                </div>
            </nav>
        </div>
        <div class="uk-container uk-section">
            
            
            <div class="uk-width-1-1 uk-visible@m">
                <h5 class="uk-heading-small uk-text-center">Enter Transaction Receipt</h5>
            </div>
            <div class="uk-width-1-1 uk-visible@m">
                <hr class="uk-divider-icon">
            </div>
            
            <ul uk-tab>
                <li><a href="#">Manual Transaction</a></li>
                <li><a href="#">Scan To Transaction</a></li>
                <li><a href="#">Scan To Receipt</a></li>
            </ul>
            
            <div class="uk-switcher">
                <div class="uk-grid-small" uk-grid>
                    <div class="uk-width-1-1">
                        <div uk-grid>
                            <div class="uk-width-1-1 uk-child-width-expand@s uk-grid-small uk-flex uk-flex-bottom uk-margin" uk-grid>
                                <div class="uk-width-1-3@m">
                                    <label class="uk-form-label" for="database_id">Database ID</label>
                                    <input id="database_id" class="uk-input uk-disabled uk-flex uk-flex-bottom" type="text">
                                </div>
                                <div class="uk-width-2-3@m uk-flex uk-flex-bottom">
                                    <button onclick="openItemsModal('itemsPage')" class="uk-button uk-button-default uk-flex uk-flex-middle uk-margin-remove-left" uk-tooltip="Select an item from the system by its database id."><span class="material-symbols-outlined" style="padding-right: 5px;">event_list</span>  Item Lookup</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="uk-width-1-1">
                        <label class="uk-form-label" for="barcode">Barcode</label>
                        <input class="uk-input uk-width-1-2@m uk-disabled" id="barcode" type="text" placeholder=" " maxlength="20">
                    </div>
                    <div class="uk-width-1-1 uk-margin-top">
                        <label class="uk-form-label" for="name">Item Name</label>
                        <input class="uk-input uk-disabled" id="name" type="text" placeholder=" " maxlength="20">
                    </div>
                    <div class="uk-width-1-1 uk-margin-top" uk-grid>
                        <div class="uk-width-1-2">
                            <label class="uk-form-label" for="QOH">Quantity on Hand</label>
                            <input class="uk-input uk-disabled" id="QOH" type="text" placeholder=" " maxlength="20">
                        </div>
                        <div class="uk-width-1-2">
                            <label class="uk-form-label" for="UOM">Unit of Measure</label>
                            <input class="uk-input uk-disabled" id="UOM" type="text" placeholder=" " maxlength="20">
                        </div>
                    </div>
                    <div class="uk-width-1-1" uk-grid>
                        <div class="uk-width-expand">
                        <label for="trans_type">Transaction Type</label>
                        <select onchange="setTransactionTypeAdjustments()" class="uk-select" id="trans_type" aria-label="Select">
                            <option value="0" disabled selected>Choose your option</option>
                            <option value="Adjust In">Adjust In</option>
                            <option value="Adjust Out">Adjust Out</option> 
                        </select>
                        </div>
                    </div>
                    <div class="uk-width-1-1 uk-flex" uk-grid>
                        <div class="uk-width-1-1 uk-child-width-expand@s uk-grid-small uk-flex uk-flex-bottom uk-margin" uk-grid>
                            <div class="uk-width-1-3@m">
                                <label class="uk-form-label" for="zone">Zone</label>
                                <input id="zone" class="uk-input uk-disabled uk-flex uk-flex-bottom" type="text">
                            </div>
                            <div class="uk-width-2-3@m uk-flex uk-flex-bottom">
                                <a id="itemLocations" href="#itemLocationsModal" class="uk-button uk-button-default uk-flex uk-flex-middle uk-disabled" uk-tooltip="See all the item's locations and their QOH" uk-toggle><span class="material-symbols-outlined" style="padding-right: 5px;">event_list</span>  Item Locations</a>
                            </div>
                        </div>
                    </div>
                    <div class="uk-width-1-1 uk-flex" uk-grid>
                        <div class="uk-width-1-1 uk-child-width-expand@s uk-grid-small uk-flex uk-flex-bottom uk-margin" uk-grid>
                            <div class="uk-width-1-3@m">
                                <label class="uk-form-label" for="location">Locations</label>
                                <input id="location" class="uk-input uk-disabled uk-flex uk-flex-bottom" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="uk-width-1-1 uk-flex" uk-grid>
                        <div class="uk-width-1-4@m">
                            <label class="uk-form-label" for="transaction_quantity">Quantity</label>
                            <input class="uk-input" id="transaction_quantity" type="text" placeholder=" " maxlength="20" value="0.00">
                        </div>
                        <div class="uk-width-1-4@m">
                            <label class="uk-form-label" for="transaction_cost">SKU cost</label>
                            <input class="uk-input" id="transaction_cost" type="text" placeholder=" " maxlength="20" value="0.00">
                        </div>  
                    </div>
                    <div class="uk-width-1-1">
                        <label class="uk-form-label" for="transaction_description">Description</label>
                        <input class="uk-input" id="transaction_description" type="text" placeholder=" " maxlength="128" value="">
                    </div>  
                    <div class="uk-width-1-1">
                        <hr class="uk-divider-icon">
                    </div>
                    <div class="uk-width-1-1 uk-flex uk-flex-right">
                        <button onclick="submitTransaction()" class="uk-button uk-button-primary">Submit</button>
                    </div>
                </div>
                <div class="uk-grid-small" uk-grid>
                    <div class="uk-width-1-1 uk-visible@m">
                        <p class="uk-text-meta">Using this method of entering transaction receipts does so by transacting a single UOM of the barcode scanned. Its important that you have the
                            Barcode input focused and use a scanner that places the characters into the field before it finishes up with a press of the ENTER key.
                        </p>
                    </div>
                    <div class="uk-width-1-1 uk-flex uk-flex-left" uk-grid>
                        <div class="uk-width-1-3@m">
                            <label class="uk-form-label" for="barcode-scan">Barcode</label>
                            <input onkeydown="addToQueue(event)" on id="barcode-scan" class="uk-input uk-flex uk-flex-bottom" type="text">
                        </div>
                        <div class="uk-width-1-3@m uk-flex uk-flex-bottom uk-flex-right@m">
                            <select id="scan_trans_type" class="uk-select" aria-label="Select">
                                <option value="Adjust Out">Adjust Out</option>
                                <option value="Adjust In">Adjust In</option>
                            </select>
                        </div>
                    </div>
                    <div class="uk-width-1-1">
                        <table class="uk-table uk-table-striped uk-table-hover">
                            <thead>
                                <tr>
                                    <th>Status</th>
                                    <th>Barcode</th>
                                    <th>Name</th>
                                    <th>Type</th>
                                    <th>Location</th>
                                </tr>
                            </thead>
                            <tbody id="scanTableBody">
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="uk-grid-small" uk-grid>
                    <div class="uk-width-1-1">
                        <p class="uk-text-meta">Using this method of entering receipts does so by adding each barcode to a list and once the receipt has been built the 
                            the system will then add the receipt to the system. Its important that you have the Barcode input focused and use a scanner that places the 
                            characters into the field before it finishes up with a press of the ENTER key.
                        </p>
                    </div>
                    <div class="uk-width-1-1" uk-grid>
                        <div>
                            <button id="receiptStart" onclick="startReceipt()" class="uk-button uk-button-default">Start Receipt</button>
                        </div>
                        <div>
                            <button id="receiptComplete" onclick="completeReceipt()" class="uk-button uk-button-default uk-disabled">Complete Receipt</button>
                        </div>
                        <div>
                            <button id="receiptClose" onclick="closeReceipt()" class="uk-button uk-button-default uk-disabled">Cancel Receipt</button>
                        </div>
                    </div>
                    <div class="uk-width-1-1">
                        <hr class="uk-divider-icon">
                    </div>
                    <div id="barcode-input" class="uk-width-1-1 uk-flex uk-flex-left uk-disabled" uk-grid>
                        <div class="uk-width-1-3@m">
                            <label class="uk-form-label" for="barcode-scan-receipt">Barcode</label>
                            <input onkeydown="addToReceipt(event)" id="barcode-scan-receipt" class="uk-input uk-flex uk-flex-bottom" type="text">
                        </div>
                    </div>
                    <div id="barcode-table" class="uk-width-1-1 uk-disabled">
                        <table class="uk-table uk-table-striped uk-table-hover">
                            <thead>
                                <tr>
                                    <th class="uk-table-shrink">Type</th>
                                    <th class="uk-table-shrink">Barcode</th>
                                    <th>Name</th>                                    
                                </tr>
                            </thead>
                            <tbody id="scanReceiptTableBody">
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- Modals -->
        <!-- This is the modal -->
        <div id="itemsModal" uk-modal>
            <div id="itemsModalInner" class="uk-modal-dialog uk-modal-body " uk-overflow-auto>
                <h2 class="uk-modal-title">Select Item</h2>
                <p>Select an Item from the system...</p>
                <div id="searchItemsForm" onkeydown="searchTable(event, 'items', 'itemsPage')" class="uk-search uk-search-default uk-align-center">
                    <input id="searchItemsInput" class="uk-border-pill uk-search-input" type="search" placeholder="" aria-label="">
                    <span class="uk-search-icon-flip" uk-search-icon></span>
                </div>
                <nav aria-label="Pagination">
                    <ul id="itemsPage" class="uk-pagination uk-flex-center" uk-margin>
                        <li><a href="#"><span uk-pagination-previous></span></a></li>
                        <li><a href="#">1</a></li>
                        <li class="uk-disabled"><span>…</span></li>
                        <li><a href="#">5</a></li>
                        <li><a href="#">6</a></li>
                        <li class="uk-active"><span aria-current="page">7</span></li>
                        <li><a href="#">8</a></li>
                        <li><a href="#"><span uk-pagination-next></span></a></li>
                    </ul>
                </nav>
                <table class="uk-table uk-table-striped uk-table-hover">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Barcode</th>
                            <th>Name</th>
                        </tr>
                    </thead>
                    <tbody id="itemsTableBody">
                    </tbody>
                </table>
            </div>
        </div>
        <!-- Item Locations Modal-->
        <div id="itemLocationsModal" uk-modal>
            <div id="itemLocationsModalInner" class="uk-modal-dialog uk-modal-body " uk-overflow-auto>
                <h2 class="uk-modal-title">Item Locations</h2>
                <table class="uk-table uk-table-striped uk-table-hover">
                    <thead>
                        <tr>
                            <th>Zone</th>
                            <th>Location</th>
                            <th>QOH</th>
                        </tr>
                    </thead>
                    <tbody id="itemLocationTableBody">
                    </tbody>
                </table>
            </div>
        </div>
        <!-- Line Edit Modal-->
        <div id="lineEditModal" uk-modal>
            <div class="uk-modal-dialog uk-modal-body">
                <h2 class="uk-modal-title">Edit Line...</h2>
                <p class="uk-text-meta">Edit any fields here for the selected Line and then save them.</p>
                <table class="uk-table uk-table-responsive uk-table-striped">
                    <thead>
                        <tr>
                            <th></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>QTY</td>
                            <td><input id="lineName" class="uk-input" type="text"></td>
                        </tr>
                        <tr>
                            <td>QTY</td>
                            <td><input id="lineQty" class="uk-input" type="text"></td>
                        </tr>
                        <tr>
                            <td>UOM</td>
                            <td>
                                <select id="lineUOM" class="uk-select" type="text">
                                    {% for unit in units %}
                                    <option value="{{unit['id']}}">{{unit['fullname']}}</option>
                                    {% endfor %}
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>COST</td>
                            <td><input id="lineCost" class="uk-input" type="text"></td>
                        </tr>
                        <tr>
                            <td>EXPIRES</td>
                            <td><input id="lineExpires" class="uk-input" type="date"></td>
                        </tr>
                    </tbody>
                </table>
                <p class="uk-text-right">
                    <button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
                    <button id="saveLineButton" class="uk-button uk-button-primary" type="button">Save</button>
                </p>
            </div>
        </div>
               
        

        {% assets "js_all" %}
        <script type="text/javascript" src="{{ ASSET_URL }}"></script>
        {% endassets %}
        <script type="text/javascript" src="/static/handlers/transactionHandler.js"></script>
    </body>
</html>