Example #1
0
def booking_history():
    cust_id = mainEngine.getCustomer(session['email'])[0]
    bookings = mainEngine.getPersonalBookingHistory(cust_id)
    cars = mainEngine.getAllCars()
    return render_template("customer/bookingHistory.html",
                           bookings=bookings,
                           cars=cars)
Example #2
0
def ongoing_booking():
    cust_id = mainEngine.getCustomer(session['email'])[0]
    bookings = mainEngine.getPersonalOngoingBooking(cust_id)
    cars = mainEngine.getAllCars()
    return render_template("customer/ongoingBooking.html",
                           bookings=bookings,
                           cars=cars)
Example #3
0
def booking_summary():
    if request.method == 'POST':
        car_id = request.form['car']
        start_date = request.form['sdate']
        start_time = request.form['stime']
        end_date = request.form['edate']
        end_time = request.form['etime']
        time = request.form['time']
        cost = request.form['cost']

        name = request.form['namecard']
        card = request.form['cardnumber']
        date = request.form['date']
        cvv = request.form['cvv']
        cust = mainEngine.getCustomer(session['email'])
        if mainEngine.card_validation(name, card, date, cvv):
            mainEngine.makeBooking(cust[0], car_id, start_date, start_time,
                                   end_date, end_time, time, cost)
            mainEngine.setCarUnavalaible(car_id)
            return redirect("/customer/ongoing-booking")
        else:
            cars = mainEngine.getCar(car_id)
            return render_template("customer/bookingPayment2.html",
                                   cars=cars,
                                   start_date=start_date,
                                   start_time=start_time,
                                   end_date=end_date,
                                   end_time=end_time,
                                   time=time,
                                   cost=cost,
                                   success=False)
Example #4
0
def booking():
    valid = True

    if request.method == 'POST':
        car_id = request.form['car']
        start_date = request.form['sdate']
        start_time = request.form['stime']
        end_date = request.form['edate']
        end_time = request.form['etime']
        if mainEngine.validateBookingTime(start_date, start_time, end_date,
                                          end_time):
            time = mainEngine.getTotalBookingTime(start_date, start_time,
                                                  end_date, end_time)
            cust = mainEngine.getCustomer(session['email'])
            plan = cust[7]
            cars = mainEngine.getCar(car_id)
            cost = 0
            if plan == 0:
                cost = mainEngine.getTotalBookingCost(start_date, start_time,
                                                      end_date, end_time,
                                                      cars[0][10])
            else:
                cost = mainEngine.getTotalBookingCost(start_date, start_time,
                                                      end_date, end_time, 15)
            return render_template("customer/bookingPayment2.html",
                                   cars=cars,
                                   start_date=start_date,
                                   start_time=start_time,
                                   end_date=end_date,
                                   end_time=end_time,
                                   time=time,
                                   cost=cost,
                                   success=True)
        else:
            valid = False

    cars = mainEngine.getAvalaibleCars()
    mark = []
    if cars:
        for car in cars:
            mark.append((float(car[12]), float(car[11]), car[1]))

    gmap = Map(
        identifier="gmap",
        varname="gmap",
        #MELBOURNE COORDINATE
        lat=-37.8136,
        lng=144.9631,
        markers={
            icons.dots.blue: mark,
        },
        style=
        "height:max-500px;max-width:1000px;margin:0;margin-left:auto;margin-right:auto;",
    )
    return render_template("customer/booking2.html",
                           cars=cars,
                           gmap=gmap,
                           valid=valid)
Example #5
0
def plan_summary():
    cust = mainEngine.getCustomer(session['email'])
    if request.method == 'POST':
        name = request.form['namecard']
        card = request.form['cardnumber']
        date = request.form['date']
        cvv = request.form['cvv']

        if mainEngine.card_validation(name, card, date, cvv):
            mainEngine.set_premium_expiry(cust[0])
        else:
            return render_template("customer/planPayment2.html", success=False)

    cust = mainEngine.getCustomer(session['email'])
    if not cust[8] or not mainEngine.validate_premium(cust[8]):
        return render_template("customer/planPayment2.html", success=True)

    return redirect("/customer/set-plan")
Example #6
0
def search_car_by_location():
    cust_id = mainEngine.getCustomer(session['email'])[0]
    address = mainEngine.getAddress(cust_id)
    car_list = mainEngine.getAvalaibleCars()
    cars = mainEngine.distance(car_list, address)
    mark = []
    if cars:
        for car in cars:
            mark.append((float(car[12]), float(car[11]), car[1]))

    gmap = Map(
        identifier="gmap",
        varname="gmap",
        #MELBOURNE COORDINATE
        lat=address[7],
        lng=address[8],
        markers={
            icons.dots.blue: mark,
        },
        style=
        "height:max-500px;max-width:1000px;margin:0;margin-left:auto;margin-right:auto;",
    )

    return render_template("/customer/searchCar.html", gmap=gmap, cars=cars)
Example #7
0
def set_standard():
    cust = mainEngine.getCustomer(session['email'])
    mainEngine.set_plan(cust[7], cust[0])
    return redirect("/customer/plan")
Example #8
0
def plan():
    cust = mainEngine.getCustomer(session['email'])
    plan = cust[7]
    return render_template("/customer/price.html", plan=plan)
Example #9
0
def register():
    error = False
    validDOB = True
    validLicense = True
    if request.method == 'POST':
        # personal details
        fname = request.form['fname']
        lname = request.form['lname']
        dob = request.form['date']
        phone = request.form['phone']
        email = request.form['email']
        password = request.form['password']
        # address details
        unit = request.form['unitno']
        street = request.form['street']
        suburb = request.form['suburb']
        state = request.form['state']
        postcode = request.form['postcode']

        string_address = postcode + ", " + state

        # license details
        lnumber = request.form['lnumber']
        country = request.form['country']
        license_state = request.form['license-state']
        issue_date = request.form['idate']
        expiry_date = request.form['edate']

        if mainEngine.check_duplicate_email(email) is False:
            if mainEngine.validateDOB(dob) is True:
                if mainEngine.validateLicenseDate(issue_date, expiry_date):
                    mainEngine.register(fname, lname, dob, email, password,
                                        phone)
                    cust_id = mainEngine.getCustomer(email)[0]
                    url = 'https://maps.googleapis.com/maps/api/geocode/json'
                    params = {
                        'sensor': 'false',
                        'address': string_address,
                        'key': 'AIzaSyApAUIt3LozCwUFBGJY3F75w6U6IcLO_Ek'
                    }
                    r = requests.get(url, params=params)
                    results = r.json()['results']
                    location = results[0]['geometry']['location']
                    mainEngine.insertAddress(cust_id, unit, street, suburb,
                                             state, postcode, location['lat'],
                                             location['lng'])
                    mainEngine.insertLicense(cust_id, lnumber, country,
                                             license_state, issue_date,
                                             expiry_date)
                    return render_template("index.html",
                                           error=False,
                                           success=True,
                                           change=False)
                else:
                    validLicense = False
            else:
                validDOB = False
        else:
            error = True
    return render_template("register.html",
                           error=error,
                           validDOB=validDOB,
                           validLicense=validLicense)