<div class="content-header">
    <div class="row">
        <div class="col-md-8">
            <h2>{{::vm.translate.get('Products')}}</h2>
        </div>
        <div class="col-md-4 text-right">
            <a ui-sref="product-create" class="btn btn-success"><span class="fa fa-plus"></span> {{::vm.translate.get('Create Product')}}</a>
        </div>
    </div>
</div>

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card" st-pipe="vm.getProducts" st-table="vm.products">
                    <div class="card-header">
                        <div class="card-tools">
                            <st-date-range predicate="CreatedOn" before="query.before" after="query.after"></st-date-range>
                        </div>
                    </div>
                    <div class="card-body p-0 table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th></th>
                                    <th st-sort="Id" class="sortable">{{::vm.translate.get('Id')}}</th>
                                    <th st-sort="Name" class="sortable">{{::vm.translate.get('Name')}}</th>
                                    <th st-sort="Name" class="sortable">{{::vm.translate.get('Sku')}}</th>
                                    <th class="text-center">{{::vm.translate.get('Has Options')}}</th>
                                    <th class="text-center">{{::vm.translate.get('Is Visible Individually')}}</th>
                                    <th class="text-center">{{::vm.translate.get('Is Featured')}}</th>
                                    <th class="text-center">{{::vm.translate.get('Is Allowed To Order')}}</th>
                                    <th class="text-right">{{::vm.translate.get('Stock Quantity')}}</th>
                                    <th class="text-center">{{::vm.translate.get('Actions')}}</th>
                                </tr>
                                <tr>
                                    <th></th>
                                    <th></th>
                                    <th>
                                        <div class="form-group">
                                            <input class="form-control" st-search="Name" />
                                        </div>
                                    </th>
                                    <th></th>
                                    <th>
                                        <div class="form-group">
                                            <select class="form-control" st-search="HasOptions">
                                                <option value="">{{::vm.translate.get('All')}}</option>
                                                <option value="true">{{::vm.translate.get('Yes')}}</option>
                                                <option value="false">{{::vm.translate.get('No')}}</option>
                                            </select>
                                        </div>
                                    </th>
                                    <th>
                                        <div class="form-group">
                                            <select class="form-control" st-search="IsVisibleIndividually">
                                                <option value="">{{::vm.translate.get('All')}}</option>
                                                <option value="true">{{::vm.translate.get('Yes')}}</option>
                                                <option value="false">{{::vm.translate.get('No')}}</option>
                                            </select>
                                        </div>
                                    </th>
                                    <th></th>
                                    <th></th>
                                    <th></th>
                                    <th></th>
                                </tr>
                            </thead>
                            <tbody ng-show="!vm.isLoading">
                                <tr ng-repeat="product in vm.products">
                                    <td><img ng-src="{{product.thumbnailUrl}}" class="img" style="max-height: 39px" /></td>
                                    <td>{{product.id}}</td>
                                    <td>{{product.name}}</td>
                                    <td>{{product.sku}}</td>
                                    <td class="text-center"><i ng-attr-class="{{product.hasOptions && 'fa fa-circle' || 'fa fa-circle-o'}}"></i></td>
                                    <td class="text-center"><i ng-attr-class="{{product.isVisibleIndividually && 'fa fa-circle' || 'fa fa-circle-o'}}"></i></td>
                                    <td class="text-center"><i ng-attr-class="{{product.isFeatured && 'fa fa-circle' || 'fa fa-circle-o'}}"></i></td>
                                    <td class="text-center"><i ng-attr-class="{{product.isAllowToOrder && 'fa fa-circle' || 'fa fa-circle-o'}}"></i></td>
                                    <td class="text-right">{{product.stockQuantity}}</td>
                                    <td class="text-center">
                                        <button ng-if="!product.isPublished" title="Publish" ng-click="vm.changeStatus(product)" class="btn btn-primary btn-xs"> <span class="fa fa-play"></span></button>
                                        <a ui-sref="product-edit({id: product.id})" title="Edit" class="btn btn-primary btn-xs"> <i class="fa fa-pen"></i></a>
                                        <button ng-click="vm.deleteProduct(product)" title="Delete" class="btn btn-danger btn-xs delete"> <i class="fas fa-times-circle"></i></button>
                                        <a ui-sref="product-translation({id: product.id, culture: culture})" class="btn btn-default btn-xs btn-translate" ng-repeat="culture in vm.enableCultures">
                                            <span class="flag flag-{{culture.substr(culture.length - 2).toLowerCase()}}" alt="{{culture}}" title="{{culture}}"></span>
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                            <tbody ng-show="vm.isLoading">
                                <tr>
                                    <td colspan="10" class="text-center">Loading ... </td>
                                </tr>
                            </tbody>
                            <!--<tfoot>
                                <tr>
                                    <td class="text-center" st-pagination="" st-items-by-page="10" st-displayed-pages="10" colspan="10"></td>
                                </tr>
                            </tfoot>-->
                        </table>
                    </div>
                    <div class="card-footer">
                        <div class="row">
                            <div class="col" ng-show="!vm.isLoading" colspan="3">{{vm.tableStateRef.pagination.totalItemCount | number:0}} {{::vm.translate.get('records found')}}</div>
                            <div class="col Page navigation" st-pagination="" st-items-by-page="10" st-displayed-pages="10"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>