$(function(){
    reset_tr_num();
});
function reset_tr_num(){
    $('table').each(function() {
        var i = 1;
        $(this).find('td.o_n').each(function () {
            $(this).html(i);
            i++;
        });
    });
}
function searchgoodslist(){
    var goods_sn=$('#goods_sn').val().trim();//商品输入框
    if (goods_sn==''){
        $.showErr('商品不能为空',0,'hc');
        return false;
    }
    var query = new Object();
    query.goods_sn = goods_sn;  //商品关键词
    $.ajax({
        url: APP+"Shop/InvoicingOrder/detail_search_goods",
        data:query,
        type:"post",
        dataType:"json",
        success: function(data){
            var html = "<option value='0'>==请选择商品==</option>";
            if(data.status == 1){
                for(var i=0;i<data.list.length;i++){
                    html += "<option value='"+data.list[i]['id']+"'>"+data.list[i]['goods_name']+"("+data.list[i]['goods_sn']+")</option>";
                }
            }else{
                $.showErr(data.msg,0,'hc');
            }
            $("#goods_list").html(html);
            return false;
        }
    });
}
/*盘点报损操作开始*/
function stock_confirm_order(id,type,status){
    var query = new Object();
    query.id = id; //订单id
    query.type = type;  //订单类型
    query.status = status; //审核状态
    query.audit_remarks = $('#remarks').val();
    $.ajax({
        url: APP+"shop/InvoicingOrder/stock_confirm_order",
        data:query,
        type:"post",
        dataType:"json",
        success: function(data){
            if(data.status==1){
                $.showSuccess(data.msg,1,'hc',function(){
                    window.location.reload();
                },function(){
                    window.location.reload();
                });
            }else{
                $.showErr(data.msg,1,'hc');
            }
        }
    });
}
/*盘点报损操作结束*/
function do_export_goods_detail(){
    var goods_id = $("[name='goods_ids']").val();
    // var shop_id = $("[name='shop_id']").val();
    var type = $("[name='type']").val();
    var data_from = $("[name='data_from']").val();
    var data_to = $("[name='data_to']").val();
    var url = APP + "shop/InvoicingOrder/goods_detail_export.html" + "&goods_id=" + goods_id + "&type=" + type +  "&data_from=" + data_from + "&data_to=" + data_to;
    window.location.href = url;
}
function do_export_stock_search(){
    var keyword = $("[name='keyword']").val();
    var catid=$("[name='catid']:checked").val();
    var suppliers_id = $("[name='suppliers_id']").val();
    var url = APP + "shop/InvoicingOrder/stock_search_export.html" + "&keyword=" + keyword +"&catid="+catid+ "&suppliers_id=" + suppliers_id;
    window.location.href = url;
}
function do_export_bad_list(){
    // var shop_id = $("[name='shop_id']").val();
    var data_from = $("[name='data_from']").val();
    var data_to = $("[name='data_to']").val();
    var url = APP + "shop/InvoicingOrder/bad_list_export.html" +  "&data_from=" + data_from + "&data_to=" + data_to;
    window.location.href = url;
}



