<form method="post" autocomplete="off" class="form-horizontal">
    <legend>Purchase Return Edit / New</legend>
    <div class="control-group">
        <label for="txtDate" class="control-label">Date</label>

        <div class="controls">
            <datepicker id="txtDate" model="voucher.Date" ng-model="voucher.Date"></datepicker>
        </div>
    </div>
    <div class="control-group" ng-repeat="journal in voucher.Journals | journalDebit:1">

        <label for="txtLedger" class="control-label">Ledger</label>

        <div class="controls">
            <input type="text" id="txtLedger" ng-autocomplete resource="Account" label="Name" model="journal.Ledger" value="{{journal.Ledger.Name}}"/>

            <div class="input-prepend">
                <span class="add-on">₹</span><input type="text" id="txtLedgerAmount" class="span2"
                                                    autocomplete="off" readonly="readonly"
                                                    placeholder="Amount" ng-model="journal.Amount"/>
            </div>
        </div>
    </div>
    <div class=" control-group" id="add">
        <label for="txtBatch" class="control-label">Product</label>

        <div class="controls">
            <input type="text" ng-autocomplete id="txtBatch" resource="Batch" label="Name" model="batch"/>
            <input type="text" id="txtQuantity" class="span2" autocomplete="off"
                   placeholder="Quantity" ng-model="quantity"/>
            <button class="btn btn-info" ng-click="addInventory()">Add <i class="icon-plus-sign icon-white"></i>
            </button>
        </div>
    </div>

    <div class="control-group">
        <label for="gvGrid" class="control-label"></label>

        <div class="controls">
            <table id="gvGrid" class="table table-condensed table-bordered table-striped">
                <thead>
                <tr>
                    <th>Product</th>
                    <th>Quantity</th>
                    <th>Rate</th>
                    <th>Tax</th>
                    <th>Discount</th>
                    <th>Amount</th>
                    <th>Delete</th>
                </tr>
                </thead>
                <tbody id="tbodyMain">
                <tr ng-repeat="inventory in voucher.Inventories">
                    <td>{{inventory.Product.Name}}</td>
                    <td>{{inventory.Quantity}}</td>
                    <td>{{inventory.Rate}}</td>
                    <td>{{inventory.Tax}}</td>
                    <td>{{inventory.Discount}}</td>
                    <td>{{inventory.Amount}}</td>
                    <td>
                        <div class="btn-group">
                            <a class="btn btn-danger" ng-click="removeInventory(inventory)"><i
                                    class="icon-trash icon-white"></i> Delete</a>
                            <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#"><span
                                    class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a ng-confirm url="/partial/purchase-return-modal.html" before="toggleEdit(inventory)"
                                       on-action="toggleEdit(inventory, true)" on-cancel="toggleEdit(inventory, false)"><i
                                        class="icon-pencil"></i> Edit</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                </tbody>
                <tfoot id="tfootMain">
                </tfoot>
            </table>
        </div>
    </div>
    <div class="control-group">
        <label for="txtNarration" class="control-label">Narration</label>

        <div class="controls">
            <textarea rows="3" id="txtNarration" class="input-block-level" ng-model="voucher.Narration"></textarea>
        </div>
    </div>
    <div class="form-actions">
        <button class="btn btn-primary" ng-click="save()"
                ng-disabled="preventAlteration(voucher)">{{voucher.VoucherID | save_button}}
        </button>
        <button class="btn btn-inverse" ng-click="post()" ng-hide="!voucher.VoucherID"
                ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
        </button>
        <button class="btn btn-danger" ng-hide="!voucher.VoucherID" ng-disabled="preventAlteration(voucher)"
                ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
                action-button-text="Delete" action-function="delete()"> Delete
        </button>
    </div>
    <div class="row-fluid">
        Created on {{voucher.CreationDate | localTime}} and Last Edited on {{voucher.LastEditDate | localTime}} by
        {{voucher.User.Name}}. Posted by {{voucher.Poster}}
    </div>
</form>