 <form class="form-horizontal" role=form autocomplete="off">
    <h2>Purchase Edit / New</h2>

    <div class="form-group">
        <label for="txtDate" class="col-md-2 control-label">Date / From</label>

        <div class="col-md-4">
            <div class="input-group">
                <input class="form-control" id="txtDate" type="text" datepicker-popup="dd-MMM-yyyy"
                       is-open="dOpen" ng-focus="dOpen = true" ng-model="voucher.Date"/>
                <span class="input-group-btn">
                    <button class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
                </span>
            </div>
        </div>

        <div class="col-md-6" ng-repeat="journal in voucher.Journals | journalDebit:-1">
            <div class="input-group">
                <input type="text" class="form-control" ng-model="journal.Ledger" autocomplete="off"
                       typeahead="account as account.Name for account in accounts($viewValue)"
                       typeahead-editable="false"/><span class="input-group-addon">₹</span>
                <input type="text" class="form-control" placeholder="Amount" value="{{journal.Amount | number:2}}"/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="txtProduct" class="col-md-2 control-label">Product</label>

        <div class="col-md-4">
            <input type="text" id="txtProduct" class="form-control" ng-model="product" autocomplete="off"
                   typeahead="product as product.Name for product in products($viewValue)"
                   typeahead-editable="false" on-return="add()" focus-on="foProduct"/>
        </div>
        <div class="col-md-2">
            <input type="text" class="form-control" placeholder="Quantity" ng-model="quantity" on-return="add()"/>
        </div>
        <div class="col-md-1">
            <input type="text" class="form-control" placeholder="Price" ng-model="product.Price" on-return="add()"/>
        </div>
        <div class="col-md-1">
            <input type="text" class="form-control" placeholder="Tax" ng-model="tax" on-return="add()"/>
        </div>
        <div class="col-md-1">
            <input type="text" class="form-control" placeholder="Discount" ng-model="discount" on-return="add()"/>
        </div>
        <div class="col-md-1">
            <button class="btn btn-info" ng-click="add()">Add <i class="glyphicon glyphicon-plus-sign"></i></button>
        </div>
    </div>

    <table 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 class="text-right">{{inventory.Quantity | number:2}}</td>
            <td class="text-right">{{inventory.Rate  | currency}}</td>
            <td class="text-right">{{inventory.Tax | percent}}</td>
            <td class="text-right">{{inventory.Discount | percent}}</td>
            <td class="text-right">{{inventory.Amount | currency}}</td>
            <td>
                <div class="btn-group">
                    <a class="btn btn-danger" ng-click="removeInventory(inventory)"><i
                            class="glyphicon glyphicon-trash"></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-click="modal(inventory)"><i class="glyphicon glyphicon-pencil"></i> Edit</a></li>
                    </ul>
                </div>
            </td>
        </tr>
        </tbody>
        <tfoot id="tfootMain">
        </tfoot>
    </table>
    <div class="form-group">
        <label for="txtNarration" class="col-md-2 control-label">Narration</label>

        <div class="col-md-10">
            <textarea rows="3" id="txtNarration" class="form-control" ng-model="voucher.Narration"></textarea>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-10 col-md-offset-2">
            <div class="img-container" ng-repeat="item in voucher.Files">
                <img ng-click="zoomImage(item)" ng-src="{{item.Thumbnail}}" class="img-thumbnail">
                <a href ng-click="deleteFile(item)" class="overlay"><i class="glyphicon glyphicon-trash"></i></a>
            </div>
            <label ng-href for="fileUp">
                <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTUwIj48cmVjdCB3aWR0aD0iMTAwIiBoZWlnaHQ9IjE1MCIgZmlsbD0iI2VlZSIvPjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9IjUwIiB5PSI3NSIgc3R5bGU9ImZpbGw6I2FhYTtmb250LXdlaWdodDpib2xkO2ZvbnQtc2l6ZToxMDBweDtmb250LWZhbWlseTpBcmlhbCxIZWx2ZXRpY2Esc2Fucy1zZXJpZjtkb21pbmFudC1iYXNlbGluZTpjZW50cmFsIj4rPC90ZXh0Pjwvc3ZnPg==" class="img-thumbnail">
            </label>
            <input type="file" id="fileUp" file-upload multiple style="display: none;" accept="image/*">
        </div>
    </div>
    <div class="form-actions">
        <button class="btn btn-primary" tan-click="save()"
                ng-disabled="preventAlteration(voucher)">{{voucher.VoucherID | save_button}}
        </button>
        <button class="btn btn-inverse" tan-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-click="confirm()"> Delete
        </button>
    </div>
    <div class="row">
        Created on {{voucher.CreationDate | localTime}} and Last Edited on {{voucher.LastEditDate | localTime}} by
        {{voucher.User.Name}}. Posted by {{voucher.Poster}}
    </div>
</form>