Exemplo n.º 1
0
def editquery(request):
    stmt = mydb.cursor()

    if request.POST:
        id = request.session['Adminid']
        name = request.POST['name']
        mail = request.POST['email']
        password = request.POST['pass']
        phone = request.POST['phone']
        salary = request.POST['salary']
        role = request.POST['role']

        sql = "UPDATE employee SET emp_name = %s, emp_email = %s, emp_pass = %s, emp_phone = %s, emp_salary = %s, emp_role = %s WHERE emp_ID = %s"
        val = (name, mail, password, phone, salary, role, id)

        stmt.execute(sql, val)
        mydb.commit()

    id = request.session['Adminid']
    stmt.execute("SELECT * FROM employee WHERE emp_ID = " + str(id))
    result = stmt.fetchone()
    context = {
        'admin': result,
    }
    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 2
0
def reservequery(request):
    stmt = mydb.cursor()
    if request.POST:
        id = request.session['clientid']
        flight_id = request.POST["flight_id"]
        priceA = request.POST['priceA']
        priceB = request.POST['priceB']
        priceC = request.POST['priceC']

        if request.POST['flightClass'] == "ClassA":
            price = priceA
        elif request.POST['flightClass'] == "ClassB":
            price = priceB
        else:
            price = priceC
        sql = "INSERT INTO transactions(tr_client, tr_flight, tr_price, tr_time) VALUES (%s, %s, %s, now())"
        val = (id, flight_id, price)

        stmt.execute(sql, val)
        mydb.commit()

    stmt.execute(
        "SELECT flights.*, timetable.tt_end, timetable.tt_hour_start, timetable.tt_hour_end FROM flights INNER JOIN timetable ON flights.flt_timetable = timetable.tt_ID WHERE DATE(flt_date) > CURDATE() ORDER BY flt_id ASC LIMIT 50"
    )
    result = stmt.fetchall()
    context = {
        'flights': result,
    }

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 3
0
def addquery(request):
    stmt = mydb.cursor()
    if request.POST:
        day = request.POST['day']
        starttime = request.POST['starttime']
        endtime = request.POST['endtime']
        plane = request.POST['plane']
        origin = request.POST['origin']
        destination = request.POST['destination']
        pa = request.POST['priceA']
        pb = request.POST['priceB']
        pc = request.POST['priceC']

        sql = 'INSERT INTO timetable(tt_plane_id, tt_start, tt_end, tt_price_a, tt_price_b, tt_price_c, tt_dayofweek, tt_hour_start, tt_hour_end) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)'
        val = (plane, origin, destination, pa, pb, pc, day, starttime, endtime)
        stmt.execute(sql, val)
        mydb.commit()

    stmt.execute(
        "SELECT timetable.*, planes.pln_name FROM timetable INNER JOIN planes ON timetable.tt_plane_id = planes.pln_ID ORDER BY tt_ID ASC"
    )
    result = stmt.fetchall()
    context = {
        "times": result,
    }

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 4
0
def editquery(request):
    stmt = mydb.cursor()

    if request.POST:
        id_time = request.POST['time_id']
        day = request.POST['day']
        starttime = request.POST['starttime']
        endtime = request.POST['endtime']
        plane = request.POST['plane']
        origin = request.POST['origin']
        destination = request.POST['destination']
        pa = request.POST['priceA']
        pb = request.POST['priceB']
        pc = request.POST['priceC']

        sql = "UPDATE timetable SET tt_plane_id = %s, tt_start = %s, tt_end = %s, tt_price_a = %s, tt_price_b = %s, tt_price_c = %s, tt_dayofweek = %s, tt_hour_start = %s, tt_hour_end = %s WHERE tt_ID = %s"
        val = (plane, origin, destination, pa, pb, pc, day, starttime, endtime,
               id_time)

        stmt.execute(sql, val)
        mydb.commit()

    stmt.execute(
        "SELECT timetable.*, planes.pln_name FROM timetable INNER JOIN planes ON timetable.tt_plane_id = planes.pln_ID ORDER BY tt_ID ASC"
    )
    result = stmt.fetchall()
    context = {
        "times": result,
    }

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 5
0
def index(request):
    stmt = mydb.cursor()

    stmt.execute("SELECT * FROM planes")
    result = stmt.fetchall()
    context = {"planes": result}
    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 6
0
def index(request):
    id = request.session['Adminid']
    stmt = mydb.cursor()
    stmt.execute("SELECT * FROM employee WHERE emp_ID = " + str(id))
    result = stmt.fetchone()
    context = {
        'admin': result,
    }
    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 7
0
def gotoedit(request, plane_id):
    stmt = mydb.cursor()
    stmt.execute("SELECT * FROM planes WHERE pln_ID = " + str(plane_id))
    result = stmt.fetchone()
    context = {
        "plane": result,
    }

    return render(request, template_name=path + "edit.html", context=context)
Exemplo n.º 8
0
def index(request):
    stmt = mydb.cursor()
    stmt.execute(
        "SELECT timetable.*, planes.pln_name FROM timetable INNER JOIN planes ON timetable.tt_plane_id = planes.pln_ID ORDER BY tt_ID ASC"
    )
    result = stmt.fetchall()
    context = {
        "times": result,
    }

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 9
0
def index(request):
    stmt = mydb.cursor()

    stmt.execute(
        "SELECT flights.*, timetable.tt_end, timetable.tt_hour_start, timetable.tt_hour_end FROM flights INNER JOIN timetable ON flights.flt_timetable = timetable.tt_ID WHERE DATE(flt_date) > CURDATE() ORDER BY flt_id ASC LIMIT 50"
    )
    result = stmt.fetchall()
    context = {
        'flights': result,
    }

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 10
0
def gotoedit(request, time_table_id):
    stmt = mydb.cursor()
    stmt.execute("SELECT * FROM timetable WHERE tt_ID = " + str(time_table_id))
    result = stmt.fetchone()
    context = {
        "time": result,
    }

    stmt.execute("SELECT * FROM planes")
    result = stmt.fetchall()
    context['planes'] = result

    return render(request, template_name=path + "edit.html", context=context)
Exemplo n.º 11
0
def gotoreserve(request, flight_id):
    stmt = mydb.cursor()
    stmt.execute(
        "SELECT flights.*, timetable.*  FROM flights INNER JOIN timetable ON flights.flt_timetable = timetable.tt_ID WHERE flt_ID = "
        + str(flight_id))
    result = stmt.fetchone()

    context = {
        'flight': result,
    }
    return render(request,
                  template_name=path + "reserve.html",
                  context=context)
Exemplo n.º 12
0
def loginadmin(request):
    stmt = mydb.cursor()
    if request.POST:
        name = request.POST['name']
        pas = request.POST['password']

        stmt.execute(
            "SELECT * FROM employee WHERE emp_name = %s AND emp_pass = %s",
            (name, pas))
        result = stmt.fetchone()
        if result:
            request.session['Admin'] = name
            request.session['Adminid'] = result[0]

    return render(request, template_name="main/templates/index.html")
Exemplo n.º 13
0
def signin(request):
    stmt = mydb.cursor()
    if request.POST:
        name = request.POST['name']
        pssword = request.POST['password']

        stmt.execute(
            "SELECT * FROM client WHERE clnt_name = %s AND clnt_pass = %s",
            (name, pssword))
        result = stmt.fetchone()
        if result:
            request.session['client'] = name
            request.session['clientid'] = result[0]
        else:
            request.session[
                'msg'] = "<div class='alert alert-danger'>Something is Wrong</div>"

    return render(request, template_name="main/templates/index.html")
Exemplo n.º 14
0
def addquery(request):
    stmt = mydb.cursor()

    if request.POST:
        plane_name = request.POST['pln_name']
        ca = request.POST['capacityA']
        cb = request.POST['capacityB']
        cc = request.POST['capacityC']

        sql = "INSERT INTO planes(pln_name, pln_c_a, pln_c_b, pln_c_c) VALUES (%s, %s, %s, %s)"
        val = (plane_name, ca, cb, cc)

        stmt.execute(sql, val)
        mydb.commit()

    stmt.execute("SELECT * FROM planes")
    result = stmt.fetchall()
    context = {"planes": result}
    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 15
0
def index(request):
    stmt = mydb.cursor()
    stmt.execute("SELECT SUM(flt_cost) FROM flights")
    cost = stmt.fetchone()
    context = {'cost': cost[0]}

    stmt.execute("SELECT COUNT(flt_id) FROM flights")
    flights = stmt.fetchone()
    context['flights'] = flights[0]

    stmt.execute("SELECT COUNT(pln_id) FROM planes")
    planes = stmt.fetchone()
    context['planes'] = planes[0]

    stmt.execute("SELECT COUNT(clnt_id) FROM client")
    clients = stmt.fetchone()
    context['clients'] = clients[0]

    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 16
0
def editquery(request):
    stmt = mydb.cursor()

    if request.POST:
        id = request.POST['id_plane']
        plane_name = request.POST['pln_name']
        ca = request.POST['capacityA']
        cb = request.POST['capacityB']
        cc = request.POST['capacityC']

        sql = "UPDATE planes SET pln_name = %s, pln_c_a = %s, pln_c_b = %s, pln_c_c = %s WHERE pln_ID = %s"
        val = (plane_name, ca, cb, cc, id)
        stmt.execute(sql, val)
        mydb.commit()

    stmt.execute("SELECT * FROM planes")
    result = stmt.fetchall()
    context = {
        "planes": result,
    }
    return render(request, template_name=path + "index.html", context=context)
Exemplo n.º 17
0
from django.shortcuts import render
from royalFlight.db import mydb

path = "userProfile/templates/"
stmt = mydb.cursor(buffered=True)

def index(request):
    return indexRec(request)


def gotoedit(request):
    id = request.session['clientid']
    stmt.execute("SELECT * FROM client WHERE clnt_ID = " + str(id))
    result = stmt.fetchone()
    context = {
        'client': result
    }
    return render(request, template_name=path + "edit.html", context=context)


def editquery(request):

    if request.POST:
        id = request.session['clientid']
        name = request.POST['name']
        mail = request.POST['email']
        password = request.POST['pass']
        phone = request.POST['phone']
        address = request.POST['address']
        ccN = request.POST['Credit']