<!--
	The ID "widget-grid" will start to initialize all widgets below 
	You do not need to use widgets if you dont want to. Simply remove 
	the <section></section> and you can use wells or panels instead 
	-->
<!-- widget grid -->
<section id="widget-grid" class="">

    <!-- row -->
    <div class="row">

        <!-- NEW WIDGET START -->
        <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

            <!-- Widget ID (each widget will need unique ID)-->
            <div class="jarviswidget" id="wid-id-4">
                <!-- widget options:
                usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                data-widget-colorbutton="false"
                data-widget-editbutton="false"
                data-widget-togglebutton="false"
                data-widget-deletebutton="false"
                data-widget-fullscreenbutton="false"
                data-widget-custombutton="false"
                data-widget-collapsed="true"
                data-widget-sortable="false"

                -->
                <header>
                    <span class="widget-icon"> <i class="fa fa-table"></i> </span>
                    <h2>库存快照列表</h2>
                </header>
                <!-- widget div-->
                <div>
                    <!-- widget edit box -->
                    <div class="jarviswidget-editbox">
                        <!-- This area used as dropdown edit box -->
                    </div>
                    <!-- end widget edit box -->
                    <!-- widget content -->
                    <div class="widget-body no-padding">
                        <div class="dt-toolbar">
                            <div class="row">
                                <div class="col-sm-3">
                                    <div class="dataTables_filter">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
                                        <input type="search" placeholder="商品编号/商品名称" data-ng-keyup="getStockDailyList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic">
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="input-group">
                                        <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" datepicker-localdate
                                               placeholder="起始日期"
                                               ng-model="queryParam.dailyDateStart"
                                               close-text="关闭"
                                               current-text="今日"
                                               clear-text="清除"
                                               is-open="datepickerSetting.dailyDateStart.opened"
                                               ng-required="true"/>
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default" ng-click="openDate($event, 0)"><i class="glyphicon glyphicon-calendar"></i></button>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="input-group">
                                        <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" datepicker-localdate
                                               placeholder="结束日期"
                                               ng-model="queryParam.dailyDateEnd"
                                               close-text="关闭"
                                               current-text="今日"
                                               clear-text="清除"
                                               is-open="datepickerSetting.dailyDateEnd.opened"
                                               ng-required="true"/>
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-default" ng-click="openDate($event, 1)"><i class="glyphicon glyphicon-calendar"></i></button>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-3">
                                    <button class="btn btn-primary" type="button" data-ng-click="getStockDailyList()">
                                        <i class="fa fa-refresh"></i>
                                        刷新
                                    </button>
                                    <button class="btn btn-primary" type="button" data-ng-click="createStockDaily()">
                                        <i class="fa fa-edit"></i>
                                        生成/更新今日快照
                                    </button>

                                    <button class="btn btn-primary" type="button" data-ng-click="exportStockDaily()">
                                        <i class="fa fa-download"></i>
                                        汇总导出库存快照
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-hover smart-form has-tickbox">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>时间</th>
                                    <th>商品名称</th>
                                    <th>商品编号</th>
                                    <th>前一日库存</th>
                                    <th>订单出库数</th>
                                    <th>订单退/换货（取消）入库数</th>
                                    <th>入库数</th>
                                    <th>破损数</th>
                                    <th>核销数</th>
                                    <th>库存</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="stockDaily in stockDailyList" ng-if="stockDailyList.length > 0" ng-mouseenter="show=true" ng-mouseleave="show=false">
                                    <td ng-bind="($index+1) +((pageInfoSetting.pageNum -1) * pageInfoSetting.pageSize)"></td>
                                    <td ng-bind="stockDaily.dailyDate| date: 'yyyy-MM-dd'"></td>
                                    <td ng-bind="stockDaily.itemName"></td>
                                    <td ng-bind="stockDaily.itemCode"></td>
                                    <td ng-bind="stockDaily.oldStockNum"></td>
                                    <td><a href="#" data-ng-click="openStockRecordDetail(stockDaily.dailyDate,stockDaily.stockId,2)">{{stockDaily.outNum}}</a></td>
                                    <td><a href="#" data-ng-click="openStockRecordDetail(stockDaily.dailyDate,stockDaily.stockId,3)">{{stockDaily.returnInNum}}</a></td>
                                    <td><a href="#" data-ng-click="openStockRecordDetail(stockDaily.dailyDate,stockDaily.stockId,1)">{{stockDaily.inNum}}</a></td>
                                    <td><a href="#" data-ng-click="openStockRecordDetail(stockDaily.dailyDate,stockDaily.stockId,4)">{{stockDaily.damagedNum}}</a></td>
                                    <td><a href="#" data-ng-click="openStockRecordDetail(stockDaily.dailyDate,stockDaily.stockId,5)">{{stockDaily.verificationNum}}</a></td>
                                    <td ng-bind="stockDaily.newStockNum"></td>
                                </tr>
                                <tr ng-if="stockDailyList == null || stockDailyList.length == 0">
                                    <td colspan="11">
                                        <div>暂无数据</div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="dt-toolbar-footer">
                            <div class="col-xs-12 col-sm-12">
                                <ug-pagination page-info="pageInfoSetting"></ug-pagination>
                            </div>
                        </div>
                    </div>
                    <!-- end widget content -->
                </div>
                <!-- end widget div -->
            </div>
            <!-- end widget -->

        </article>
        <!-- WIDGET END -->

    </div>

    <!-- end row -->

</section>
<!-- end widget grid -->


<script type="text/ng-template" id="stockRecordList.html">
    <div class="modal-header">
        <h3 class="modal-title">变更明细</h3>
    </div>
    <div class="modal-body">
        <div class="table-responsive">
            <table class="table table-striped table-condensed table-hover smart-form has-tickbox">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>变更时间</th>
                    <th>商品名称</th>
                    <th>商品编号</th>
                    <th>变更数量</th>
                    <th>订单号</th>
                    <th>备注</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="stockRecord in stockRecordList" ng-if="stockRecordList.length > 0" ng-mouseenter="show=true" ng-mouseleave="show=false">
                    <td ng-bind="($index+1) +((pageInfoRecordSetting.pageNum -1) * pageInfoRecordSetting.pageSize)"></td>
                    <td ng-bind="stockRecord.insertDate| date: 'yyyy-MM-dd HH:mm:ss'"></td>
                    <td ng-bind="stockRecord.itemName"></td>
                    <td ng-bind="stockRecord.itemCode"></td>
                    <td ng-bind="stockRecord.changeNum"></td>
                    <td ng-bind="stockRecord.orderNo"></td>
                    <td ng-bind="stockRecord.remark"></td>
                </tr>
                <tr ng-if="stockRecordList == null || stockRecordList.length == 0">
                    <td colspan="11">
                        <div>暂无数据</div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="dt-toolbar-footer">
            <div class="col-xs-12 col-sm-12">
                <ug-pagination page-info="pageInfoRecordSetting"></ug-pagination>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-warning" ng-click="cancel()">关闭</button>
    </div>
</script>