def if_card():
    print("Enter card number : ")
    Billing.card_number = input()
    print("Enter cvv number : ")
    Billing.cvv_number = input()
    print("Enter expiry date : ")
    Billing.expiry_date = input()
    print("Enter the name on card : ")
    Billing.name_on_card = input()
    print("Enter grid_card_number(H-I-K) : ")
    Billing.grid_card_number = input()
    if validate_card() == True:
        if Billing.card_number.startswith("4"):
            print("Card is valid! Type Visa")
            print("Amount paid successfully !")
        elif Billing.card_number.startswith("5"):
            print("Card is valid! Type MasterCard")
            print("Amount paid successfully !")
        elif Billing.card_number.startswith("6"):
            print("Card is valid! Type Rupay")
            print("Amount paid successfully !")
        else:
            print("Card is valid! Type 'others'")
            print("Amount paid successfully !")
    else:
        print("Invalid card. Please enter card details again.")
        if_card()
    ViewDBbilling.db_updating_transection_table()
    ViewDBbilling.db_deleting_after_payment()
    take_feedback()
def display_cart():
    ViewDBbilling.db_display_cart()
    fetching_items_available()
    checking_availability()
    if len(Billing.items_not_available) != 0:
        displaying_unavailable_items()
    else:
        dine_delivery()
def start_billing():
    print("Do you want to Bill, Cancel or Save for latter? (B/C/S)")
    Billing.start_billing_ans = input()
    start_billing_ans = Billing.start_billing_ans
    if start_billing_ans.upper() == "B":
        check_for_empty()
    elif start_billing_ans.upper() == "S":
        print(
            "Your data has been saved in the cart. Thank you and come back soon!"
        )
    elif start_billing_ans.upper() == "C":
        ViewDBbilling.db_start_billing()
        print("Your data has been deleted. Thank you and come back soon!")
    else:
        print("You have entered an invalid entry. Kindly chose again.")
        start_billing()
def processing_unavailable_items():
    answer = "a"
    if len(Billing.food_ordered) == len(Billing.items_not_available):
        print("Will go to kautilya's function latter.")
    else:
        print(
            "Do you want to continue billing without the unavailable item(s)? (Y/N)"
        )
        answer = input()

    if answer.upper() == "Y":
        ViewDBbilling.db_processing_unavailable_items()
        dine_delivery()
    elif answer.upper() == "N":
        print("Will go to kautilya's function latter.")
    elif answer.upper() != "Y" and answer.upper() != "N" and answer.upper(
    ) != "A":
        print("Invalid entry. Kindly enter again.")
        processing_unavailable_items()
def take_feedback():
    print("Provide Rating: ")
    ratings = input()
    Billing.rating_ans = int(ratings)
    ViewDBbilling.db_update_rating(int(ratings))

    print("Did you like the service? (Y/N)")
    Billing.like_ans = input()

    if Billing.like_ans.upper() == "Y":
        ViewDBbilling.db_take_feedback_first()

    if Billing.like_ans.upper() == "N":
        ViewDBbilling.db_take_feedback_second()
    print("Thank you for you feedback. Have a nice day!")
def fetching_items_available():
    ViewDBbilling.db_fetching_items_available()
def fetching_chosen_restaurant():
    ViewDBbilling.db_fetching_chosen_restaurant()
    display_first_line()
def check_for_empty():
    check = ViewDBbilling.db_check_for_empty()
    if check == 0:
        return 0
    else:
        return 1
def if_cash():
    print("Amount paid successfully !")
    ViewDBbilling.db_updating_transection_table()
    ViewDBbilling.db_deleting_after_payment()
    take_feedback()
def if_door_deliver():
    delivery_charges = ViewDBbilling.db_if_door_deliver()
    Billing.total_charge += delivery_charges
    print("Delivery charges = ", delivery_charges)
def calculating_total_charge():
    ViewDBbilling.db_calculating_total_charge()
def display_full_cart():
    ViewDBbilling.db_display_full_cart()
def updating_total_price():
    ViewDBbilling.db_updating_total_price()
def check_for_empty():
    check = ViewDBbilling.db_check_for_empty()
    if check == 0:
        print("Your cart is empty.!")
    else:
        fetching_chosen_restaurant()