<form class="form-horizontal" role=form>
    <h2>Receipt 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"
                       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">
                <select id="ddlLedger" class="form-control" ng-model="journal.Ledger.LedgerID"
                        ng-options="l.LedgerID as l.Name for l in ledgers"> </select><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="txtAccount" class="col-md-2 control-label">Account</label>

        <div class="col-md-6">
            <input type="text" id="txtAccount" class="form-control" ng-model="account"
                   typeahead="account as account.Name for account in accounts($viewValue)"
                   typeahead-editable="false"/>
        </div>
        <div class="col-md-4">
            <div class="input-group">
                <span class="input-group-addon">₹</span>
                <input type="text" id="txtAmount" class="form-control" autocomplete="off" placeholder="Amount"
                       ng-model="amount" on-return="add()"/>
                <span class="input-group-btn">
                    <button class="btn btn-info" ng-click="add()">Add <i class="glyphicon glyphicon-plus-sign"></i>
                    </button>
                </span>
            </div>
        </div>
    </div>
    <table class="table table-condensed table-bordered table-striped">
        <thead>
        <tr>
            <th>Name</th>
            <th>Amount</th>
            <th>Delete</th>
        </tr>
        </thead>
        <tbody id="tbodyMain">
        <tr ng-repeat="journal in voucher.Journals | journalDebit:-1">
            <td>{{journal.Ledger.Name}}</td>
            <td class="text-right">{{journal.Amount | currency}}</td>
            <td>
                <div class="btn-group">
                    <a class="btn btn-danger" ng-click="removeJournal(journal)"><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(journal)"><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-offset-2 col-md-10">
            <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>
    <div class="col-md-offset-2 col-md-10">
        <small>Created on {{voucher.CreationDate | localTime}} and Last Edited on {{voucher.LastEditDate | localTime}}
            by {{voucher.User.Name}}. Posted by {{voucher.Poster}}
        </small>
    </div>
</form>
