<div class="col-md-12" ng-controller="MakeDataTableEntryController">
    <ul class="breadcrumb">
        <li ng-show="client"><a
                ng-href="#/viewclient/{{entityId}}">{{clientName}}</a></li>
        <li ng-show="group"><a
                ng-href="#/viewgroup/{{entityId}}">{{groupName}}</a></li>
        <li ng-show="center"><a
                ng-href="#/viewcenter/{{entityId}}">{{centerName}}</a></li>
        <li ng-show="loanproduct"><a
                ng-href="#/viewclient/{{clientId}}">{{LoanHolderclientName}}</a></li>
        <li ng-show="loanproduct"><a
                ng-href="#/viewloanaccount/{{entityId}}">{{loanproductName}}</a></li>
        <li ng-show="office"><a
                ng-href="#/viewoffice/{{entityId}}">{{officeName}}</a></li>
        <li ng-show="savingsaccount"><a
                ng-href="#/viewclient/{{clientId}}">{{savingsaccountholderclientName}}</a></li>
        <li ng-show="savingsaccount"><a
                ng-href="#/viewsavingaccount/{{entityId}}">{{savingsAccount}}</a></li>
    </ul>
<form class="form-horizontal well"  ng-submit="submit()">

    <div class="error" ng-show="errorStatus || errorDetails">
        <label>{{"label.error" | translate}}</label>
        <label ng-show="errorStatus">{{errorStatus}}</label>
        <label ng-hide="errorStatus" ng-repeat="error in errorDetails">
            {{error.code | translate:error.args}}-{{error.field}}
        </label>
    </div>
    <fieldset>
        <legend>{{ 'label.heading.makedatatableentry' | translate }}</legend>
        <h3>{{ 'label.heading.datatablename' | translate }}-<strong>{{tableName}}</strong></h3>
        <hr/>
        <div class="form-group" ng-repeat="columnHeader in columnHeaders">
            <label class="control-label col-sm-3">{{ columnHeader.columnName | prettifyDataTableColumn }}
                <span ng-show="!columnHeader.isColumnNullable" class="required">*</span>
            </label>

            <div class="col-sm-3">
                <input ng-show="fieldType(columnHeader.columnDisplayType) == 'TEXT'" type="text"
                       ng-model="formData[columnHeader.columnName]" class="form-control"/>
                <input ng-show="fieldType(columnHeader.columnDisplayType) == 'DATE'" type="text"
                       datepicker-pop="dd MMMM yyyy" ng-model="formDat[columnHeader.columnName]"
                       is-open="opened{{$index}}" class="form-control"/>
                <div ng-show="fieldType(columnHeader.columnDisplayType) == 'DATETIME'" class="form-inline">
                    <div class="form-group">
                        <input type="text" datepicker-pop="dd MMMM yyyy"
                               ng-model="formDat[columnHeader.columnName].date"
                               is-open="opened{{$index}}" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <input type="time" placeholder="HH:MM:SS"
                               ng-model="formDat[columnHeader.columnName].time" class="form-control"/>
                    </div>
                </div>
                <div ng-show="fieldType(columnHeader.columnDisplayType) == 'BOOLEAN'">
                    <label class="radio-inline">
                        <input type="radio" ng-model="formData[columnHeader.columnName]"
                               value="true"/>
                        {{'label.input.true' | translate}}
                    </label>
                    <label class="radio-inline">
                        <input type="radio" ng-model="formData[columnHeader.columnName]"
                               value="false"/>
                        {{'label.input.false' | translate}}
                    </label>
                </div>
                <span data-ng-switch on="columnHeader.columnDisplayType">
                    <select ng-show="fieldType(columnHeader.columnDisplayType) == 'SELECT'"
                            data-ng-switch-when="CODELOOKUP"
                            ng-model="formData[columnHeader.columnName]"
                            ng-options="columnValue.id as columnValue.value for columnValue in columnHeader.columnValues"
                            value="{{columnValue.id}}" class="form-control">
                        <option value="">{{'label.selectone' | translate}}</option>
                    </select>
                    <div  ng-show="showSelect==true">
                        <select ng-show="fieldType(columnHeader.columnDisplayType) == 'SELECT'"
                                data-ng-switch-when="CODEVALUE"
                                ng-model="formData[columnHeader.columnName]"
                                ng-options="columnValue.value as columnValue.value for columnValue in columnHeader.columnValues"
                                value="{{columnValue.id}}" class="form-control">
                            <option value="">{{'label.selectone' | translate}}</option>
                        </select>
                    </div>
                    <div ng-show="showSelect==false">
                        <select ng-show="fieldType(columnHeader.columnDisplayType) == 'SELECT'"
                                data-ng-switch-when="CODEVALUE"
                                chosen="columnHeader.columnValues"
                                ng-model="formData[columnHeader.columnName]"
                                ng-options="columnValue as columnValue.value for columnValue in columnHeader.columnValues"
                                value="{{columnValue.id}}" class="form-control"
                                ng-change="changeVillage(formData[columnHeader.columnName])">
                            <option value=""> {{'label.selectone' | translate}}</option>
                        </select>
                    </div>
                </span>
            </div>
        </div>
        <div class="col-md-offset-3">
            <a id="cancel" class="btn btn-default" ng-click="cancel()">{{ 'label.button.cancel' | translate }}</a>
            <button id="save" type="submit" class="btn btn-primary" has-permission='CREATE_{{tableName}}'>{{ 'label.button.save' | translate }}</button>
        </div>
    </fieldset>
</form>
</div>
