def user_get(request):
    """
       消耗统计
    """
    head_lst = [
        {'width': 50, 'name': u'使用时间'},
        {'width': 50, 'name': u'角色名'},
        {'width': 50, 'name': u'物品名称'},
        {'width': 50, 'name': u'数量'},
        {'width': 50, 'name': u'事件'},
    ]
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:

        if request.method == 'POST' :
            start_date = request.POST.get("search_start_date")
            #end_date = request.POST.get("search_end_date")
            server_id = int(request.POST.get("server_id"))
            user_id=str(request.POST.get("user_id"))
            platform_id=request.POST.get('platform_id')
            try:
                start_date_date = datetime.datetime.strptime(start_date, "%m/%d/%Y").date()
            except:
                start_date_date = datetime.datetime.now().date()
            #end_date_date = datetime.datetime.strptime(end_date, "%m/%d/%Y").date()

            server_list, platform_list = _get_server_list()
            #return render_to_response("gm/user_data_search.html", {'head_lst': head_lst, 'search_start_date': start_date, 'search_end_date': end_date,  'server_list': server_list,'platform_id':'None'}, RequestContext(request))

            #print server_list
            #分表设置显示
            if user_id<>'':
                from apps.logs.gm.user_data_search.user_get_log import get_table
                row_lst =get_table(start_date_date,  user_id,server_id)
                #     print server_list
                #  print row_lst
                return render_to_response("gm/user_get.html", {'account':manager.account,'btn_lst':btn_lst,'row_lst': row_lst,'head_lst': head_lst, 'search_start_date': start_date,  'server_list': server_list,'platform_id':platform_id, 'cur_server_id': server_id,'user_id':user_id}, RequestContext(request))
            else:
                row_lst = []
                now_date_str = datetime.date.today().strftime("%m/%d/%Y")
                start_date = now_date_str
                end_date = now_date_str
                server_list, platform_list = _get_server_list()
                #some_list=cost_item_dict.keys()
                return render_to_response("gm/user_get.html", {'account':manager.account,'btn_lst':btn_lst,'row_lst': row_lst,'head_lst': head_lst, 'search_start_date': start_date,   'server_list': server_list,'platform_id':'None', 'cur_server_id': server_id}, RequestContext(request))

        else:
            row_lst = []
            now_date_str = datetime.date.today().strftime("%m/%d/%Y")
            start_date = now_date_str
            end_date = now_date_str
            server_list, platform_list = _get_server_list()
            #some_list=cost_item_dict.keys()
            return render_to_response("gm/user_get.html", {'account':manager.account,'btn_lst':btn_lst,'row_lst': row_lst,'head_lst': head_lst, 'search_start_date': start_date,   'server_list': server_list,'platform_id':'None'}, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/login/')
def equipment_strengthening_record(request):
    """
        装备强化记录
    """
    head_lst = [
    {'width': 50, 'name': u'操作时间'},
    {'width': 50, 'name': u'角色名'},
    {'width': 50, 'name': u'用户事件'},
    {'width': 50, 'name': u'消耗金币'},
    {'width': 50, 'name': u'消耗强化石'},
    ]
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:
        if request.method == 'POST':
            start_date = request.POST.get("start_date")
            # end_date = request.POST.get("end_date")
            # start_date = request.POST.get("search_start_date")
            try:
                start_date_date = datetime.datetime.strptime(start_date, "%m/%d/%Y").date()
            except:
                start_date_date = datetime.datetime.now().date()
            # channel_id = int(request.POST.get("channel_id"))
            server_id = int(request.POST.get("server_id"))




            # start_date_date = datetime.datetime.strptime(start_date, "%m/%d/%Y").date()
            # end_date_date = datetime.datetime.strptime(end_date, "%m/%d/%Y").date()
            # 分表设置显示
            # 总表行
            from apps.logs.gm.user_data_search.equipment_strengthening_record import get_table
            row_lst =get_table(start_date_date,server_id)
            print row_lst
            server_list, platform_list = _get_server_list()
            return render_to_response("gm/equipment_strengthening_record.html", {'account':manager.account,'btn_lst':btn_lst,'row_lst': row_lst, 'head_lst': head_lst, 'start_date': start_date,'end_date': start_date_date, 'server_list': server_list, 'cur_server_id': server_id}, RequestContext(request))
        else:
            row_lst = []
            now_date_str = datetime.date.today().strftime("%m/%d/%Y")
            start_date = now_date_str
            end_date = now_date_str
            server_list, platform_list = _get_server_list()
            return render_to_response("gm/equipment_strengthening_record.html", {'account':manager.account,'btn_lst':btn_lst,'row_lst': row_lst, 'head_lst': head_lst, 'start_date': start_date, 'end_date': start_date, 'server_list': server_list}, RequestContext(request))

    else:
        return HttpResponseRedirect('/Tyranitar6/login/')
def user_cost(request):
    """
       消耗统计
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()

    if btn_lst:
        head_lst = [
            {
                'width': 50,
                'name': u'使用时间'
            },
            {
                'width': 50,
                'name': u'角色名'
            },
            {
                'width': 50,
                'name': u'物品名称'
            },
            {
                'width': 50,
                'name': u'数量'
            },
            {
                'width': 50,
                'name': u'事件'
            },
        ]
        if request.method == 'POST':
            start_date = request.POST.get("search_start_date")
            #end_date = request.POST.get("search_end_date")
            server_id = int(request.POST.get("server_id"))
            user_id = str(request.POST.get("user_id"))
            platform_id = request.POST.get('platform_id')
            try:
                start_date_date = datetime.datetime.strptime(
                    start_date, "%m/%d/%Y").date()
            except:
                start_date_date = datetime.datetime.now().date()
            #end_date_date = datetime.datetime.strptime(end_date, "%m/%d/%Y").date()

            server_list, platform_list = _get_server_list()
            #return render_to_response("gm/user_data_search.html", {'head_lst': head_lst, 'search_start_date': start_date, 'search_end_date': end_date,  'server_list': server_list,'platform_id':'None'}, RequestContext(request))

            #print server_list
            #分表设置显示
            if user_id <> '':
                from apps.logs.gm.user_data_search.user_cost_log import get_table
                row_lst = get_table(start_date_date, user_id, server_id)
                #     print server_list
                print row_lst
                return render_to_response(
                    "gm/user_cost.html", {
                        'account': manager.account,
                        'btn_lst': btn_lst,
                        'row_lst': row_lst,
                        'head_lst': head_lst,
                        'search_start_date': start_date,
                        'server_list': server_list,
                        'platform_id': platform_id,
                        'cur_server_id': server_id,
                        'user_id': user_id
                    }, RequestContext(request))
            else:
                row_lst = []
                now_date_str = datetime.date.today().strftime("%m/%d/%Y")
                start_date = now_date_str
                end_date = now_date_str
                server_list, platform_list = _get_server_list()
                #some_list=cost_item_dict.keys()
                return render_to_response(
                    "gm/user_cost.html", {
                        'account': manager.account,
                        'btn_lst': btn_lst,
                        'row_lst': row_lst,
                        'head_lst': head_lst,
                        'search_start_date': start_date,
                        'server_list': server_list,
                        'platform_id': 'None',
                        'cur_server_id': server_id
                    }, RequestContext(request))

        else:
            row_lst = []
            now_date_str = datetime.date.today().strftime("%m/%d/%Y")
            start_date = now_date_str
            end_date = now_date_str
            server_list, platform_list = _get_server_list()
            #some_list=cost_item_dict.keys()
            return render_to_response(
                "gm/user_cost.html", {
                    'account': manager.account,
                    'btn_lst': btn_lst,
                    'row_lst': row_lst,
                    'head_lst': head_lst,
                    'search_start_date': start_date,
                    'server_list': server_list,
                    'platform_id': 'None'
                }, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/login/')
def equipment_strengthening_record(request):
    """
        装备强化记录
    """
    head_lst = [
        {
            'width': 50,
            'name': u'操作时间'
        },
        {
            'width': 50,
            'name': u'角色名'
        },
        {
            'width': 50,
            'name': u'用户事件'
        },
        {
            'width': 50,
            'name': u'消耗金币'
        },
        {
            'width': 50,
            'name': u'消耗强化石'
        },
    ]
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:
        if request.method == 'POST':
            start_date = request.POST.get("start_date")
            # end_date = request.POST.get("end_date")
            # start_date = request.POST.get("search_start_date")
            try:
                start_date_date = datetime.datetime.strptime(
                    start_date, "%m/%d/%Y").date()
            except:
                start_date_date = datetime.datetime.now().date()
            # channel_id = int(request.POST.get("channel_id"))
            server_id = int(request.POST.get("server_id"))

            # start_date_date = datetime.datetime.strptime(start_date, "%m/%d/%Y").date()
            # end_date_date = datetime.datetime.strptime(end_date, "%m/%d/%Y").date()
            # 分表设置显示
            # 总表行
            from apps.logs.gm.user_data_search.equipment_strengthening_record import get_table
            row_lst = get_table(start_date_date, server_id)
            print row_lst
            server_list, platform_list = _get_server_list()
            return render_to_response(
                "gm/equipment_strengthening_record.html", {
                    'account': manager.account,
                    'btn_lst': btn_lst,
                    'row_lst': row_lst,
                    'head_lst': head_lst,
                    'start_date': start_date,
                    'end_date': start_date_date,
                    'server_list': server_list,
                    'cur_server_id': server_id
                }, RequestContext(request))
        else:
            row_lst = []
            now_date_str = datetime.date.today().strftime("%m/%d/%Y")
            start_date = now_date_str
            end_date = now_date_str
            server_list, platform_list = _get_server_list()
            return render_to_response(
                "gm/equipment_strengthening_record.html", {
                    'account': manager.account,
                    'btn_lst': btn_lst,
                    'row_lst': row_lst,
                    'head_lst': head_lst,
                    'start_date': start_date,
                    'end_date': start_date,
                    'server_list': server_list
                }, RequestContext(request))

    else:
        return HttpResponseRedirect('/Tyranitar6/login/')