Ejemplo n.º 1
0
def main(result):
    from db_handlers import db_article
    from db_handlers import db_price
    from admin_pages import admin_homepage
    from . import manage_articles
    import loggedin
    print("Add Article")

    print("Enter a name for new article: ")
    article_name = input()
    print("Enter price: ")
    article_price = input()
    print("Enter stock: ")
    article_stock = input()
    print("Enter lease duration: ")
    article_expiration = input()

    id = db_article.add_article(article_name, article_price, article_stock,
                                article_expiration)
    #db_stock.add_stock(id, article_stock)
    db_price.add_price(article_price, loggedin.currentuser, id)
    #db_duration.add_expiration(article_expiration, loggedin.currentuser, id)

    print("Article added. Returning to homepage.")
    admin_homepage.main(result)
Ejemplo n.º 2
0
def select_opt_manage_articles(buttonpressed, result):

    if buttonpressed == '1':
        #print("Add")
        from admin_pages import add_article
        add_article.main(result)

    elif buttonpressed == '2':
        #print("Edit")
        from admin_pages import edit_article
        edit_article.main(result)

    elif buttonpressed == '3':
        #print("Delete")
        from admin_pages import delete_article
        delete_article.main(result)

    elif buttonpressed == '4':
        print("Going back")
        from admin_pages import admin_homepage
        admin_homepage.main(result)

    else:
        print("Invalid option.")
        select_opt_manage_articles()
Ejemplo n.º 3
0
def define_recipient(result):

    print("Send message")
    print("Enter message recipient (email or all)")
    recipient_input = input()

    if recipient_input == 'all' or recipient_input == 'ALL':
        print("Send all")
        print("Enter subject")
        subject_input = input()
        print("Enter content of the message")
        content_input = input()
        msgid = db_msg.create_message(subject_input, content_input, result)
        userlist = db_user.get_all_user_ids()
        for user in userlist :
            db_msg.create_flag_message(msgid[0], user[0])

    elif db_user.check_if_email_exists(recipient_input):
        print("Enter subject")
        subject_input = input()
        print("Enter content of the message")
        content_input = input()
        msgid = db_msg.create_message(subject_input, content_input, result)
        userid = db_user.get_user_by_email(recipient_input)
        db_msg.create_flag_message(msgid[0],userid)
        print("Message sent.")
    else:
        print("That's not a valid recipient.")
        define_recipient(result)


    admin_homepage.main(result)
Ejemplo n.º 4
0
def by_timeframe(result):

    print("Introduce start day:")
    start_day = input()
    print("Introduce start month:")
    start_month = input()
    print("Introduce start year:")
    start_year = input()

    print("Introduce end day:")
    end_day = input()
    print("Introduce end month:")
    end_month = input()
    print("Introduce end year:")
    end_year = input()

    from db_handlers import db_rent
    moneymade = db_rent.get_rent_by_timeframe(start_day, start_month,
                                              start_year, end_day, end_month,
                                              end_year)
    print('We made ' + str(moneymade[0]) + " euros between " + start_day +
          "-" + start_month + "-" + start_year + " and " + end_day + "-" +
          end_month + "-" + end_year)

    print("Returning to homepage.")
    admin_homepage.main(result)
Ejemplo n.º 5
0
def mainlog():
    import db_handlers
    from admin_pages import admin_homepage
    #from client_pages import client_homepage
    import loggedin
    while True:
        print("Login")
        print("Email:")
        email = input()
        print("Password:"******"Something went wrong. Try again")
            continue
        elif result is None:
            print("Login information was wrong. Try again")
            continue
        else:
            print("Login successful.")
            loggedin.currentuser = result
            if db_handlers.checkifadmin(result):
                admin_homepage.main(result)
                break
            else:
                client_id = db_handlers.get_user(result)
                client = db_handlers.get_user_overview(client_id)
                client_name = client[1]
                #client_homepage.main(result)
                break
Ejemplo n.º 6
0
def main(result):
    print("View all articles")
    from db_handlers import db_article
    list = db_article.get_article_overview()
    for article in list:
        print("Name: " + article[1] + " Price: " + str(article[2]) +
              " Stock: " + str(article[3]))

#going back
    print("Back")
    from admin_pages import admin_homepage
    admin_homepage.main(result)
Ejemplo n.º 7
0
def all_time(result):
    print("All time sales:")
    from db_handlers import db_rent
    list = db_rent.get_article_rent_overview()
    sum = 0
    for rent in list:
        # list of all sales
        print("Purchase date: " + str(rent[1]) + " Price: " + str(rent[2]))
        # sum of all prices in that list
        sum += rent[2]

    print("Total revenue: " + str(sum) + " euros.")

    print("Returning to homepage.")
    admin_homepage.main(result)
Ejemplo n.º 8
0
def select_opt_business_stats(buttonpressed, result):
    if buttonpressed == '1':
        print("All time")
        all_time(result)

    elif buttonpressed == '2':
        print("Last month")
        by_timeframe(result)

    elif buttonpressed == '3':
        print("By article")
        by_article(result)

    elif buttonpressed == '4':
        print("Going back")
        from admin_pages import admin_homepage
        admin_homepage.main(result)
    else:
        print("bad option. try again.")
        select_opt_business_stats()
Ejemplo n.º 9
0
def main(result):
    from db_handlers import db_article
    from db_handlers import db_price
    from db_handlers import db_duration
    from admin_pages import admin_homepage
    from . import manage_articles
    import loggedin

    print("Delete article")
    print("Introduce article to delete.")
    article_name_input = input()
    if db_article.check_if_article_exists(article_name_input):

        article = db_article.get_article_by_filter('name', article_name_input)
        print("Name : " + article[1])
        print("Price : " + str(article[2]))
        print("Stock : " + str(article[3]))
        print("Is this the article you wish to delete?(Y/N)")
        buttonpressed = input()
        if buttonpressed == 'y' or 'Y':
            db_article.delete_article(article[0])
            print("Article deleted. Returning to homepage")
            admin_homepage.main(result)
        else:
            print("Not deleted. Returning to homepage")
            admin_homepage.main(result)

    else:
        print("Couldn't find the article. Returning to homepage.")
        admin_homepage.main(result)
Ejemplo n.º 10
0
def by_article(result):

    print("Introduce article to search its stats.")
    article_id_input = input()

    from db_handlers import db_rent
    if db_rent.check_if_rent_exists(article_id_input):
        from db_handlers import db_rent
        n = db_rent.get_numberoftimes_by_article(article_id_input)
        article = db_article.get_article_by_filter('id', article_id_input)

        sum = n[0] * article[2]

        print("Total revenue of that artice: " + str(sum) + " euros.")

    else:
        print("Couldn't find rents with that article. Returning to homepage.")
        from admin_pages import main
        admin_homepage.main(result)

    print("Returning to homepage.")
    admin_homepage.main(result)
Ejemplo n.º 11
0
def main(result):
    from db_handlers import db_user
    from db_handlers import db_client
    print("Enter user ID you want to add balance to.")
    user_id_input = input()

    if db_user.get_user(user_id_input):
        print("Is this the user you wish to add balance to?(Y/N)")
        buttonpressed = input()
        if buttonpressed == 'y' or 'Y':
            print("Enter the amount to add")
            amount_input = input()
            db_client.add_balance(user_id_input, amount_input)
            #get existing balance, update query to change the balance to the existing balance plus the amount_input
            print("Amount added. Returning to homepage")
            admin_homepage.main(result)
        else:
            print("Nothing was done. Returning to homepage")
            admin_homepage.main(result)

    else:
        print("Couldn't find the user. Returning to homepage.")
        admin_homepage.main(result)