Exemple #1
0
def showNames(tableName,itemID):
    idName_parent = getParentIDName(tableName)
    if itemID==None:
        cursor.execute("SELECT * FROM {tableName}".format(tableName=tableName))
    else:
        cursor.execute("SELECT * FROM {tableName} WHERE {idName_parent} = \"{itemID}\"".format(tableName=tableName,idName_parent=idName_parent,itemID=itemID))
    count = 1
    for x in cursor:
        print(count,":",x[1])
        count+=1
    menu.back()
Exemple #2
0
def addLogWithRef(tableName,itemID_parent,index):
    if index == -1:
        return
    idName_parent = getParentIDName(tableName)
    columnName = getColumnName(tableName)
    
    item = getItemName(tableName,index)
    duration = uInput.getDuration()
    date = uInput.getDate(0)
    status = uInput.getStatus()
    duedate = uInput.getDue()
    cursor.execute("INSERT INTO {tableName} ({idName_parent},{columnName},duration,timestamp,status,duedate) VALUES (\"{itemID_parent}\",\"{item}\",{duration},\"{date}\",\"{status}\",\"{duedate}\")".format(tableName=tableName,idName_parent=idName_parent,columnName=columnName,itemID_parent=itemID_parent,item=item,duration=duration,date=date,status=status,duedate=duedate))
    db.commit()
    print("Item successfully created.")
    menu.back()
Exemple #3
0
def createItem(tableName,itemID_parent,allowDup):
    print(uInput.promptNew)
    item = uInput.getName(tableName)

    if itemExistsByName(tableName,itemID_parent,item) and allowDup==False:
        print("Item already exists.")
    else:
        idName_parent = getParentIDName(tableName)
        columnName = getColumnName(tableName)
        if idName_parent==None:
            cursor.execute("INSERT INTO {tableName} ({columnName}) VALUES (\"{item}\")".format(tableName=tableName,columnName=columnName,item=item))
        elif tableName=="main_tasks":
            cursor.execute("INSERT INTO {tableName} ({columnName},{idName_parent}) VALUES (\"{item}\",\"{itemID_parent}\")".format(tableName=tableName,columnName=columnName,idName_parent=idName_parent,item=item,itemID_parent=itemID_parent))
        elif tableName=="subtasks_2021":
            duration = uInput.getDuration()
            date = uInput.getDate(0)
            status = uInput.getStatus()
            duedate = uInput.getDue()
            cursor.execute("INSERT INTO {tableName} ({idName_parent},{columnName},duration,timestamp,status,duedate) VALUES (\"{itemID_parent}\",\"{item}\",{duration},\"{date}\",\"{status}\",\"{duedate}\")".format(tableName=tableName,idName_parent=idName_parent,columnName=columnName,itemID_parent=itemID_parent,item=item,duration=duration,date=date,status=status,duedate=duedate))
        db.commit()
        print("Item successfully created.")
    menu.back()
Exemple #4
0
def deleteItem(tableName,itemID_parent,itemNum):
    if itemNum == -1:
        return
    elif tableName=="tasks_list" and itemNum == 0:
        return
    if itemID_parent==None:
        itemID = itemNum
    else:
        itemID = getItemID(tableName,itemID_parent,itemNum)
    idName = getIDName(tableName) 
    cursor.execute("DELETE FROM {tableName} WHERE {idName} = \"{itemID}\"".format(tableName=tableName,idName=idName,itemID=itemID))
    if tableName=="tasks_list":
        resetPriKey("subtasks_2021")
        resetPriKey("main_tasks")
        resetPriKey("tasks_list")
    elif tableName=="main_tasks":
        resetPriKey("subtasks_2021")
        resetPriKey("main_tasks")
    elif tableName=="subtasks_2021":
        resetPriKey("subtasks_2021")
    db.commit()
    print("Item successfully deleted.")
    menu.back()
Exemple #5
0
def all(tableName, itemID_parent):

    cursor.execute(
        "SELECT taskID, task FROM main_tasks WHERE tlID = \"{itemID_parent}\"".
        format(itemID_parent=itemID_parent))
    tasks = cursor.fetchall()

    for x in tasks:
        print(menu.design.BOLD + menu.design.UNDERLINE + x[1] +
              menu.design.END)
        cursor.execute(
            "SELECT DISTINCT subtask FROM subtasks_2021 WHERE taskID = \"{x}\""
            .format(x=x[0]))
        subtaskNames = [row[0] for row in cursor.fetchall()]
        subtasks = []
        inProgress = []
        upNext = []
        completed = []
        for i in subtaskNames:
            duration = 0
            cursor.execute(
                "SELECT subtask, status, duedate, timestamp, duration FROM subtasks_2021 WHERE subtask = \"{i}\" ORDER BY timestamp DESC"
                .format(i=i))
            getSimilar = cursor.fetchall()
            for t in getSimilar:
                duration = t[4] + duration
            item = getSimilar[0]
            item = item + (duration, )
            if item[1] == "In Progress":
                inProgress.append(item)
            elif item[1] == "Up Next":
                upNext.append(item)
            elif item[1] == "Completed":
                completed.append(item)

            inProgress.reverse()
            upNext.reverse()
            completed.reverse()

        subtasksFormatted = []
        item = ()
        colour = ""
        dueDate = datetime.datetime(1, 1, 1)

        for a in inProgress:
            subtasks.append(a)
        for b in upNext:
            subtasks.append(b)
        for c in completed:
            subtasks.append(c)

        countY = 0
        for y in subtasks:
            itemName = y[0]

            if y[1] == "Up Next":
                colour = menu.design.RED
            elif y[1] == "In Progress":
                colour = menu.design.YELLOW
            elif y[1] == "Completed":
                colour = menu.design.GREEN

            if dbTable.hasDue(y[2]):
                dueDate = y[2]
                dueDate.strftime("%m/%d/%Y")
            else:
                dueDate = None

            formattedDuration = round(y[5] / 60, 2)

            item = (itemName,
                    "[{duration} hrs]".format(duration=formattedDuration),
                    "[{colour}{status}{end}]".format(colour=colour,
                                                     status=y[1],
                                                     end=menu.design.END),
                    "Due: {dueDate}".format(dueDate=dueDate))
            subtasksFormatted.append(item)
            countY += 1

        print(tabulate(subtasksFormatted, tablefmt='plain'))
        print("\n")
    menu.back()