def give_big_size(value_tuple):
    try:
        global last_viewed_tuple
        global cur_item_tuple
        value_list = list(value_tuple)
        if value_list[2] == "xxxl":
            bf.hanprt("Sorry we only have upto size XXXL")
        else:    
            if value_tuple[2] == "s":
                value_list[2] = "m"
            if value_tuple[2] == "m":
                value_list[2] = "l"
            if value_tuple[2] == "l":
                value_list[2] = "xl"
            if value_tuple[2] == "xl":
                value_list[2] = "xxl"
            if value_tuple[2] == "xxl":
                value_list[2] = "xxxl"

            bf.random_pr_string(("No problem I will give you a bigger size"
                                ,"No problem"
                                ,"Sure"
                                ,"This is bigger"
                                ,"I hope this will fit you"
                                ,"Try this size"))
           
            value_tuple_2 = tuple(value_list)
            last_viewed_tuple =  value_tuple_2
            cur_item_tuple =  value_tuple_2
            data_list = udb.items_available_to_buy(value_tuple_2)
            showcase_designs(data_list)
    except:
        bf.hanprt("Sorry an error occured in getting you the big size")
def give_small_size(value_tuple):
    try:
        global last_viewed_tuple
        global cur_item_tuple
        value_list = list(value_tuple)
        if value_list[2] == "s":
            bf.hanprt("Sorry we don't have any size smaller than S")
        else:    
            if value_tuple[2] == "xxxl":
                value_list[2] = "xxl"
            if value_tuple[2] == "xxl":
                value_list[2] = "xl"
            if value_tuple[2] == "xl":
                value_list[2] = "l"
            if value_tuple[2] == "l":
                value_list[2] = "m"
            if value_tuple[2] == "m":
                value_list[2] = "s"

            bf.random_pr_string(("No problem I will  give you a small size"
                                ,"No problem"
                                ,"Sure"
                                ,"This is smalller"
                                ,"I hope this will fit you"
                                ,"Try this size"))
           
            value_tuple_2 = tuple(value_list)
            last_viewed_tuple =  value_tuple_2
            cur_item_tuple =  value_tuple_2
            data_list = udb.items_available_to_buy(value_tuple_2)
            showcase_designs(data_list)
            #prev_item_tuple =  value_tuple_2
    except:
        bf.hanprt("Sorry an error occured in getting you the small size")
def create_profile(username):
    try:
        """CREATING the user profile"""
        
        if(bool(udb.check_table(str(username)+"_profile"))):
            bf.random_pr_string(("Welcome again." , "We love to see your face... Welcome again"))
        else:

            udb.create_profile_table(username)
            pass#del
    except:
        bf.hanprt("Sorry an error occured in creating new profie")
def remove_from_cart(value_tuple, username):
    """This function removes item from cart
    f = "DELETE FROM "+ str(username)  + "_cart"
        mycursor.execute(f)
        mycon.commit()    """
    """
    #del_to_cart  = "DELETE FROM "+ username +"_cart (item_type , gender , size  , prize , colour , brand , quantity , amount) VALUES (%s ,%s , %s , %s , %s , %s , %s ,%s)"
    del_to_cart  = "DELETE FROM "+ username +"_cart (item_type , gender , size  , prize , colour , brand ) VALUES (%s ,%s , %s , %s , %s , %s """
    try:
        filter_0 = ""
        filter_1 = ""
        filter_2 = ""
        filter_3 = ""
        filter_4 = ""
        filter_5 = ""
        filter_6 = ""
        additional_statement = ""  #where clause
        if value_tuple[0] != "":
            filter_0 = "item_type = '" + value_tuple[0] + "' and "
        if value_tuple[1] != "":
            filter_1 = "gender = '" + value_tuple[1] + "' and "
        if value_tuple[2] != "":
            filter_2 = "size = '" + value_tuple[2] + "'  and "
        if value_tuple[3] != "":
            filter_3 = "prize = '" + value_tuple[3] + "'  and "
        if value_tuple[4] != "":
            filter_4 = "colour = '" + value_tuple[4] + "'  and "
        if value_tuple[5] != "":
            filter_5 = "brand = '" + value_tuple[5] + "'  and "
        if value_tuple[6] != "":
            filter_6 = "quantity = '" + value_tuple[6] + "'  and "

        if ((value_tuple[0] != "") or (value_tuple[1] != "")
                or (value_tuple[2] != "") or (value_tuple[3] != "")
                or (value_tuple[4] != "") or (value_tuple[5] != "")
                or (value_tuple[6] != "")):
            additional_statement = "WHERE "

        DISPLAYING_FORMULA = "DELETE FROM " + username + "_cart     " + additional_statement + filter_0 + filter_1 + filter_2 + filter_3 + filter_4 + filter_5 + filter_6
        d = DISPLAYING_FORMULA[0:-4]
        mycursor.execute(d)

        #mycursor.execute(del_to_cart , value_tuple)
        mycon.commit()
        bf.random_pr_string(
            ("Removed from cart", "Item deleted from cart",
             "Item removed to cart", "Removed", "Done", "Deleted"))

    except:
        bf.hanprt("Sorry an error occured in removing from cart from database")
def display_profile(item_list):
    """THis function displays the user profile"""
    try:
        if item_list != []:
            bf.random_pr_string(
                ("Your customer loves these", "History of the user",
                 "Profile ", "Showing the profile"))
            bf.nnprt("")
            #bf.line("_",130)
            bf.nnprt(bf.center_align("_", 149))
            #bf.nnprt("|___ITEM____|__GENDER__|__SIZE___|____PRIZE__|_COLOUR_|__BRAND_|__QUANTY_|___AMOUNT___|__PAYMENT_MOD__|__DATE_AND_TIME____|")
            bf.nnprt("|__" + bf.left_align("ITEM", 10).upper() + "|__" +
                     bf.left_align("gender", 7).upper() + "|__" +
                     bf.left_align("SIZE", 7).upper() + "|__" +
                     bf.left_align("PRIZE", 13).upper() + "|__" +
                     bf.left_align("COLOUR", 10).upper() + "|__" +
                     bf.left_align("BRAND", 15).upper() + "|__" +
                     bf.left_align("QUANTITY", 10).upper() + "|__" +
                     bf.left_align("AMOUNT", 13).upper() + "|__" +
                     bf.left_align("PAYMENT_MOD", 12).upper() + "|__" +
                     bf.left_align("DATE AND TIME", 20).upper() + "|")

            for i in item_list:

                p = str(i[3])
                q = str(i[6])
                a = str(i[7])
                d = str(i[9])
                #print(d)
                #bf.easy_center_align( q + "pcs. of " +  i[0] + " of brand " + i[5].upper() + " of size " +i[2].upper() + " of colour " + i[4].upper() + " of prize Rs." + p + "/-")

                bf.nnprt("|__" + bf.left_align(i[0], 10).upper() + "|__" +
                         bf.left_align(i[1], 7).upper() + "|__" +
                         bf.left_align(i[2], 7).upper() + "|__Rs." +
                         bf.left_align(p, 10).upper() + "|__" +
                         bf.left_align(i[4], 10).upper() + "|__" +
                         bf.left_align(i[5], 15).upper() + "|__" +
                         bf.left_align(q, 10).upper() + "|__Rs." +
                         bf.left_align(a, 10).upper() + "|__" +
                         bf.left_align(i[8], 12).upper() + "|__" +
                         bf.left_align(d, 20).upper() + "|")
            #bf.line("_",130)
            bf.nnprt(bf.center_align("_", 149))
            bf.nnprt("")
        else:
            bf.hanprt("No History available")

    except:
        bf.easy_center_align("Sorry an error occured displaying the profile")
def add_to_cart(value_tuple, username):
    """This function - the items selected by the user to the cart"""

    try:
        if value_tuple == ():
            #bf.hanprt("Sorry you have not asked me of anything to buy")
            #bf.hanprt("Try saying like 'I want to buy'")
            pass
        else:

            value_tuple = (get_full_values_of_item(value_tuple))

            p = str(value_tuple[3])
            check_quantity_formula = "SELECT quantity FROM inventory WHERE item_type = '" + value_tuple[
                0] + "'  and   gender  = '" + value_tuple[
                    1] + "' and size  = '" + value_tuple[
                        2] + "'and prize = '" + p + "' and colour = '" + value_tuple[
                            4] + "' and brand = '" + value_tuple[5] + "'"
            mycursor.execute(check_quantity_formula)

            data = mycursor.fetchall()
            quantity_available = int(data[0][0])
            quantity_needed = int(value_tuple[6])
            if (quantity_needed <= quantity_available):

                final_list = []
                final_list.append(value_tuple[0])
                final_list.append(value_tuple[1])
                final_list.append(value_tuple[2])
                final_list.append(p)
                final_list.append(value_tuple[4])
                final_list.append(value_tuple[5])
                final_list.append(quantity_needed)
                amount = int(p) * int(quantity_needed)
                final_list.append(amount)
                final_tuple = tuple(final_list)

                INSERT_TO_cart = "INSERT INTO " + username + "_cart (item_type , gender , size  , prize , colour , brand , quantity , amount) VALUES (%s ,%s , %s , %s , %s , %s , %s ,%s)"
                mycursor.execute(INSERT_TO_cart, final_tuple)
                mycon.commit()
                bf.random_pr_string(("Added to cart", "New Item added",
                                     "Item added to cart", "Added", "Done"))
            else:
                bf.hanprt(
                    "Sorry , we don't have this much quantity available right now the maxinum quantity you can get is "
                    + str(quantity_available))
    except:
        bf.easy_center_align("Sorry an error occured in adding to cart")
def display_stocks(item_list):
    try:
        if item_list != []:
            bf.random_pr_string((
                "This is what we have",
                "We have these",
                "This is the stock",
                "Stock available with us",
                "Items we have",
                "Available stock",
            ))

            bf.line("_", 90)
            bf.center_align("_", 20)
            #bf.nnprt("|___ITEM____|__GENDER__|__SIZE___|____PRIZE__|_COLOUR_|__BRAND_|__QUANTY_|")
            bf.nnprt(("|__" + bf.left_align("ITEM", 10).upper() + "|__" +
                      bf.left_align("gender", 7).upper() + "|__" +
                      bf.left_align("SIZE", 7).upper() + "|__" +
                      bf.left_align("PRIZE", 10).upper() + "|__" +
                      bf.left_align("COLOUR", 10).upper() + "|__" +
                      bf.left_align("BRAND", 15).upper() + "|__" +
                      bf.left_align("QUANTITY", 10) + "|"))

            for i in item_list:

                p = str(i[3])
                q = str(i[6])
                #bf.easy_center_align( q + "pcs. of " +  i[0] + " of brand " + i[5].upper() + " of size " +i[2].upper() + " of colour " + i[4].upper() + " of prize Rs." + p + "/-")

                bf.nnprt("|__" + bf.left_align(i[0], 10).upper() + "|__" +
                         bf.left_align(i[1], 7).upper() + "|__" +
                         bf.left_align(i[2], 7).upper() + "|__Rs." +
                         bf.left_align(p, 7).upper() + "|__" +
                         bf.left_align(i[4], 10).upper() + "|__" +
                         bf.left_align(i[5], 15).upper() + "|__" +
                         bf.left_align(q, 10).upper() + "|")
            bf.line("_", 90)
            bf.nnprt("")
        else:
            bf.hanprt("No Item available in the stocks")

    except:
        bf.easy_center_align(
            "Sorry an error occured in finding whats in the stock")
def print_cart(item_list):
    try:
        """This function prints the cart"""
        if item_list != []:
            bf.random_pr_string(("You have selected " ,
                                  "This is what you have selected" ,
                                  "Your cart contains" ,
                                  "Items you have added" ,))
            for i in item_list:
                
                p = str(i[3])
                q = str(i[6])
                a = str(i[7])
                
                bf.easy_center_align(q +"pcs of " + i[0] + "("+i[1].upper()+") of brand " + i[5].upper() + " of size " +i[2].upper() + " of colour " + i[4].upper() + " of prize Rs." + p + "/-. Amount Rs." + a + "/-")
        else:
            bf.hanprt("Your cart is empty you have not added anything to your cart")
    except:
        bf.hanprt("Sorry an error occured in printing the cart")
def showcase_designs(item_list):
    try:
        if item_list != []:
            bf.random_pr_string(("Here are some beautiful designs for you" ,
                                  "You may like these designs" ,
                                  "I am sure you will love them" ,
                                  "Please have a look to them",
                                  "These designs are awesome" ,
                                  "Try these" ,))
            
            for i in item_list:
                
                p = str(i[3])
                
                bf.easy_center_align("A " + i[0] + " of brand " + i[5].upper() + " of size " +i[2].upper() + " of colour " + i[4].upper() + " of prize Rs." + p + "/-")
        else:
            bf.hanprt("Sorry sir we don't have this item available at this moment")
    except:
        bf.hanprt("Sorry an error occured in showcasing what to buy")
def add_entire_stock(value_tuple):
    """Add entire stocks completely whole row
    bf.nnprt(value_tuple)
    bf.nnprt(type(value_tuple[0]))
    bf.nnprt(type(value_tuple[1]))
    bf.nnprt(type(value_tuple[2]))
    bf.nnprt(type(value_tuple[3]))
    bf.nnprt(type(value_tuple[4]))
    bf.nnprt(type(value_tuple[5]))
    bf.nnprt(type(value_tuple[6]))
    bf.nnprt(type(value_tuple))
    """
    try:
        mycursor.execute(INSERTION_FORMULA, value_tuple)
        #mycursor.commit()
        bf.random_pr_string(("New stock added successfully", "New stock added",
                             "Stock added", "Done"))
        # mycursor.execute("INSERT INTO inventory (item_type , gender , size  , prize , colour , brand , quantity) VALUES ((jean, m, 'm , 800 , blue , gucci , 4 ))")
        mycon.commit()

        #bf.nnprt(item_type , gender , size  , prize , colour , brand , quantity)
    except:
        bf.easy_center_align("Sorry an error occured in adding entire stock")
Beispiel #11
0
def chat(t):
    """This function chats with the user """
    if m(t, r"hi") or m(t, r"hello") or m(t, r"hey") or m(t, r"hello") or m(
            t, r"hlo") or m(t, r"hello"):
        bf.random_pr_string(
            ("Hey", "Hlo", "Hey..How are you?", "Hi..How are you?",
             "Hello..How can I help you? ", "Hi...What can i do for you?",
             "Hi..", "Nice to see you"))
    elif (m(t, r"how") and m(t, r"you(r)?")):
        bf.random_pr_string(
            ("I am fine...How are you?", "Fine", "I am fine...What about you?",
             "As usual...Fine", "I am nice", "Fine...Thanks for asking"))
    elif (m(t, r"what(')?(s)?") and m(t, r"name")) or (m(t, r"who")
                                                       and m(t, r"you(r)?")):
        bf.hanprt("Hey I am AutoKB...How can I help you?")
    elif ((m(t, r"what") and m(t, r"do")) or (m(t, r"help"))
          or m(t, r"command(s)?")):
        bf.hanprt("I am here to help you...I can help you in many ways")
        bf.hanprt("Try asking me to display items by saying 'I WANT TO BUY...")
        bf.hanprt("'ADD TO CART' to add to cart")
        bf.hanprt("'BILL' to start you billing")
        bf.hanprt("ADD TO CART' to add to cart")
        bf.hanprt("Ya its that simple'")
    elif (m(t, r"thank(s)?") or m(t, r"thank(-| )you")):
        bf.random_pr_string(("Welcome", "I am glad to hear that from you"))
    elif (m(t, r"shut up") or (m(t, r"close") and m(t, r"mouth"))):
        bf.hanprt("I am sorry if I offended you")
    elif (m(t, r"awesome") or m(t, r"fine") or m(t, r"good") or m(t, r"nice")
          or m(t, r"osm") or m(t, r"beauiful(l)?") or m(t, r"liked(d)?")
          or m(t, r"wonderful(l)?") or m(t, r"fantastic") or m(t, r"fabulous")
          or m(t, r"amazing") or m(t, r"lovely") or m(t, r"unique")
          or m(t, r"suberb") or m(t, r"super") or m(t, r"great(s| work)?")):
        bf.random_pr_string(
            ("Thanks", "Good", "Nice", "Huh", "Hmmm", "Glad to here"))
    elif (m(t, r"bye(e|ee|eee|eeee)?") or m(t, r"go")):
        bf.random_pr_string(("Bye...See you afterwards", "Bye...Bye...Bye...",
                             "See you later"))
    elif (m(t, r"you") and m(t, r"can")):
        bf.random_pr_string(
            ("No.I cannot", "Let me guess......No.", "What do you think?",
             "May be...", "But i will some day"))
    elif (m(t, r"aw(w|ww|www|wwww)?") or m(t, r"hm(m|mm|mmm|mmmm)?")):
        bf.random_pr_string(
            ("I literally hate it.", "Please don't say this again",
             "What do you think?", "May be...", "But i will some day"))
    elif (m(t, r"no") or m(t, r"never") or m(t, r"yes") or m(t, r"may be")):
        bf.random_pr_string(("Ok...", "Hmmm", "No Problem"))
    elif (m(t, r"available")):
        bf.hanprt("We have Items - Jeans,Shirts,T-shirts,Tops,Pants")
        bf.hanprt("We have Sizes - S to XXXL")
        bf.hanprt("For both Boys and Girls")
    elif (m(t, r"sorry")):
        bf.random_pr_string(
            ("Its ok..", "No problem", "Np", "I don't have any problem"))
    elif (m(t, r"o(o|oo|ooo|oooo)?k(kk|kkk|kkkk)?") or m(
            t,
            r"o(o|oo|ooo|oooo)?k(kk|kkk|kkkk)?a(aa|aaa|aaaa)?y(y|yy|yyy|yyyy)?"
    ) or m(t, r"k")) or m(t, r"oh(h|hh|hhh|hhhhh)?"):
        bf.random_pr_string(("Hmmm", "Ok", "Okay"))
    elif (m(t, r"so") and m(t, r"what(s)?")):
        bf.hanprt("You quess what")
    elif (m(t, r"what(s)?") or m(t, r"when(s)?") or m(t, r"where(s)?")
          or m(t, r"who(s|se)?")):
        bf.random_pr_string(
            ("Please you tell me....I am just a beta version",
             "Sorry i am new to this world...can't say anything", "No answer",
             "No guesses", "Sorry i don't know"))
    elif (m(t, r"favourite")):
        bf.hanprt("Sorry but algorithm don't let me choose something....")

    elif (m(t, r"who(s)?") and m(t, r"ma(de|ke)")):
        bf.hanprt("I master INFINITY made me")
    elif (m(t, r"when(s)?") and m(t, r"b(orn|irth)")):
        bf.hanprt("I was not born...I was an idea which is in front of you")
    elif m(t, r"foolish(s)?") or m(t, r"looser(s)?") or m(
            t, r"idiot(s)?") or m(t, r"stupid(s)?") or m(t, r"dumb(s)?"):
        bf.random_pr_string(("No.", "No you are.", "Same to you."))
    elif ((m(t, r"have") or (m(t, r"keep")))) and (((m(t, r"have")))) and ((
        (m(t, r"jean(s)?")) or (m(t, r"pant(s)?")) or (m(t, r"shirt(s)?")) or
        (m(t, r"t(-)?shirt(s)?")) or m(t, r"top(s)?"))) and (m(t, r"you(r)?")):
        bf.hanprt("Yes,We have this item available.")
        bf.hanprt("If you want to buy,ask me 'I WANT TO BUY...'")
    elif ((m(t, r"have") or
           (m(t, r"keep")))) and (((m(t, r"have")))) and (m(t, r"you(r)?")):
        bf.hanprt("Sorry , we don't have this item available.")
        bf.hanprt(
            "But we have jeans,pants,t-shirts,shirts and tops for girls.'")

    else:
        bf.random_pr_string(
            ("Sorry I cannot recorgnised your command",
             "Sorry please try to rephrase your command",
             "Please try to rephrase", "Sorry I did not understand",
             "Ask me again in another manner",
             "If you don't know the commands ask me for HELP"))