def pricing_main():
    print('pricing_main')
    username = login_check()
    #print(len(username))
    if (username is None):
        redirect()
    #section_no= 1
    #username ='******'
    pricing1 = Pricing_procedure()
    pricelist3, overall_total = pricing1.get_totals( username)
    print(pricelist3)
    return bottle.template('pricing_main', sectiontotal='test for section total', username = username, pricelist=pricelist3, overall_total = overall_total)
def pricing_calc():
    print('pricing_calc')
    username = login_check()
    #print(len(username))
    if (username is None):
        redirect() 
    #retrieve information from price calculator
    edited_values = []
    edited_values = bottle.request.forms.getlist('quantity')
    section_no = bottle.request.forms.get('section_no')
    print (edited_values)
    print (section_no)
    pricing1 = Pricing_procedure()
    pricing1.apply_calc(edited_values, section_no, username)
    pricing1 = Pricing_procedure()
    pricelist3, overall_total = pricing1.get_totals(username)
    print(pricelist3)
    bottle.redirect('/pricing/' + section_no)
def pricing_section(section_no):
    print('pricing_section', section_no)
    username = login_check()
    #print(len(username))
    if (username is None):
        redirect()

    index_costs = bottle.request.forms.get('index_costs')
    if not index_costs:
        index_costs = ""

    pricing1 = Pricing_procedure()
    #username = username + '_pricing'
    # check if the pricing template has been generated
    # if not generate the pricing in list
    print('check')
    if  not pricing1.check_pricing_exist(username):
        pricelist1 = pricing1.set_pricing(username)
        print ('check', pricelist1)
    #section_no = 1
    pricelist2 = pricing1.get_pricing(section_no, username)
    print ('p2  for sections', pricelist2)

    return template('pricing', pricelist=pricelist2, section_no=section_no, username=username)