from unitls.LogerinTxt import app_logger
from .flightDB import flightDB


def infoConfirm(fdb:flightDB,flighttype,flightid,displayMode,selectedtime):
    try:
        peopleSchedule_sts2en={3:"放行",4:"勤务1",5:"勤务2",6:"工1",7:"工2",8:"工3"}
        if displayMode =="A":
            if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
                flightid_new=flightid+"-1"+"-A"
            elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
                flightid_new = flightid + "-2" + "-A"
        elif displayMode =="B":
            if flighttype =="短停接" or flighttype =="航后" or flighttype =="特后前接" or flighttype =="停场":
                flightid_new=flightid+"-1"+"-B"
            elif flighttype =="短停送" or flighttype =="航前" or flighttype =="特后前送":
                flightid_new = flightid + "-2" + "-B"
        peopleSchedule_sts=fdb.queryTabel("peopleSchedule{}".format(selectedtime),"*","编号='%s'"%flightid_new)
        newdic={}
        if len(peopleSchedule_sts) != 0:
            for i in range(3,8):
                if "√" not in peopleSchedule_sts[0][i] and peopleSchedule_sts[0][i] !="":
                    newitem=peopleSchedule_sts[0][i]+"√"
                    newdic[peopleSchedule_sts2en[i]]="'%s'"%newitem
            fdb.upDateItem("peopleSchedule{}".format(selectedtime),newdic,"编号='%s'"%flightid_new)
    except Exception as e:
        app_logger.log_error(e)