<div class="panel panel-default">
    <div class="panel-heading">
        <h2>{{::vm.translate.get('Shipping - Table Rate Configuration')}}</h2>
    </div>
    <div class="panel-body">
        <h4>Price and Destination configuration</h4>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>{{::vm.translate.get('Country')}}</th>
                    <th>{{::vm.translate.get('State/Province')}}</th>
                    <th>{{::vm.translate.get('District')}}</th>
                    <th>{{::vm.translate.get('ZipCode')}}</th>
                    <th class="text-right">{{::vm.translate.get('Minimum Order Amount')}}</th>
                    <th class="text-right">{{::vm.translate.get('Shipping Price')}}</th>
                    <th>{{::vm.translate.get('Note')}}</th>
                    <th>{{::vm.translate.get('Actions')}}</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat-start="priceAndDestination in vm.pricesAndDestinations">
                    <td>{{priceAndDestination.countryName || 'All shipping enabled countries'}}</td>
                    <td>{{priceAndDestination.stateOrProvinceName || 'All states/provinces'}}</td>
                    <td>{{priceAndDestination.districtName || 'All districts'}}</td>
                    <td>{{priceAndDestination.zipCode}}</td>
                    <td class="text-right">{{priceAndDestination.minOrderSubtotal | number}}</td>
                    <td class="text-right">{{priceAndDestination.shippingPrice | number}}</td>
                    <td>{{priceAndDestination.note}}</td>
                    <td>
                        <button ng-click="vm.startEditingPriceAndDestination(priceAndDestination)" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-pencil"></span></button>
                        <button ng-click="vm.deletePriceAndDestination(priceAndDestination)" class="btn btn-danger btn-xs delete"> <span class="glyphicon glyphicon-remove"></span></button>
                    </td>
                </tr>
                <tr ng-if="priceAndDestination.isEditing" ng-repeat-end>
                    <td>
                        <select class="form-control" ng-change="vm.onCountrySelected(priceAndDestination.countryId)" ng-model="priceAndDestination.countryId"
                                ng-options="country.id as country.name for country in vm.countries">
                            <option value="">All shipping enabled countries</option>
                        </select>
                    </td>
                    <td>
                        <select class="form-control" ng-change="vm.onStateOrProvinceSelected(priceAndDestination.stateOrProvinceId)" ng-model="priceAndDestination.stateOrProvinceId"
                                ng-options="item.id as item.name for item in vm.statesOrProvinces">
                            <option value="">All States/Provinces</option>
                        </select>
                    </td>
                    <td>
                        <select class="form-control" ng-model="priceAndDestination.districtId"
                                ng-options="item.id as item.name for item in vm.districts">
                            <option value="">All Districts</option>
                        </select>
                    </td>
                    <td>
                        <input type="text" class="form-control" ng-model="priceAndDestination.zipCode" />
                    </td>
                    <td>
                        <div class="input-number">
                            <input id="orderAmount_{{priceAndDestination.id}}" type="text" decimal maxlength="10" ng-model="priceAndDestination.minOrderSubtotal" class="form-control" />
                            <label for="orderAmount_{{priceAndDestination.id}}" class="form-control">{{priceAndDestination.minOrderSubtotal | number}}</label>
                        </div>
                    </td>
                    <td>
                        <div class="input-number">
                            <input id="price_{{priceAndDestination.id}}" type="text" decimal maxlength="10" ng-model="priceAndDestination.shippingPrice" class="form-control" />
                            <label for="price_{{priceAndDestination.id}}" class="form-control">{{priceAndDestination.shippingPrice | number}}</label>
                        </div>
                    </td>
                    <td>
                        <input ng-model="priceAndDestination.note" class="form-control" />
                    </td>
                    <td>
                        <button type="button" ng-click="vm.updatePriceAndDestination(priceAndDestination)" class="btn btn-default">Save</button>
                        <button type="button" class="btn btn-default" ng-click="priceAndDestination.isEditing = false">Cancel</button>
                    </td>
                </tr>
                <tr>
                    <td>
                        <select class="form-control" ng-change="vm.onCountrySelected(vm.addingPriceAndDestination.countryId)" ng-model="vm.addingPriceAndDestination.countryId"
                                ng-options="country.id as country.name for country in vm.countries">
                            <option value="">All shipping enabled countries</option>
                        </select>
                    </td>
                    <td>
                        <select class="form-control" ng-change="vm.onStateOrProvinceSelected(vm.addingPriceAndDestination.stateOrProvinceId)" ng-model="vm.addingPriceAndDestination.stateOrProvinceId"
                                ng-options="item.id as item.name for item in vm.statesOrProvinces">
                            <option value="">All States/Provinces</option>
                        </select>
                    </td>
                    <td>
                        <select class="form-control" ng-model="vm.addingPriceAndDestination.districtId"
                                ng-options="item.id as item.name for item in vm.districts">
                            <option value="">All Districts</option>
                        </select>
                    </td>
                    <td>
                        <input type="text" class="form-control" ng-model="vm.addingPriceAndDestination.zipCode" />
                    </td>
                    <td>
                        <div class="input-number">
                            <input id="orderAmount_0" type="text" decimal maxlength="10" ng-model="vm.addingPriceAndDestination.minOrderSubtotal" class="form-control" />
                            <label for="orderAmount_0" class="form-control">{{vm.addingPriceAndDestination.minOrderSubtotal | number}}</label>
                        </div>
                    </td>
                    <td>
                        <div class="input-number">
                            <input id="price_0" type="text" decimal maxlength="10" ng-model="vm.addingPriceAndDestination.shippingPrice" class="form-control" />
                            <label for="price_0" class="form-control">{{vm.addingPriceAndDestination.shippingPrice | number}}</label>
                        </div>
                    </td>
                    <td>
                        <input ng-model="vm.addingPriceAndDestination.note" class="form-control" />
                    </td>
                    <td>
                        <button ng-click="vm.addPriceAndDestination()" title="Add" class="btn btn-primary btn-xs"> <span class="glyphicon glyphicon-plus"></span></button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>