Esempio n. 1
0
def my_applications():
    if (get_username() == ""):
        flash ("Please Login!")
        return redirect(url_for('auth.login'))
    username = get_username()
    cursor.execute("SELECT * FROM leave_application WHERE employee_id = %s ORDER BY leave_id DESC", (username,))
    leaves = cursor.fetchall()
    cursor.execute("SELECT * FROM comments ORDER BY leave_id DESC")
    comments = cursor.fetchall()
    cursor.execute("SELECT * FROM leaves_left WHERE employee_id = %s ORDER BY year ASC", (username,))
    leaves_left = cursor.fetchall()
    return render_template('user/leaves/my_applications.html', leaves = leaves, comments = comments, leaves_left = leaves_left, title="My Application" , username = username, isadmin = get_isadmin(), role = get_role())
Esempio n. 2
0
def employees():
    cursor.execute("SELECT * FROM employee ORDER BY employee_id ASC ")
    employees = cursor.fetchall()
    cursor.execute(
        "SELECT * FROM department WHERE department_id != 'NONE' ORDER BY department_id ASC"
    )
    departments = cursor.fetchall()
    return render_template('about/employees.html',
                           title='Employees',
                           employees=employees,
                           departments=departments,
                           username=get_username(),
                           isadmin=get_isadmin(),
                           role=get_role())
Esempio n. 3
0
def employees():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute("SELECT * FROM employee ORDER BY employee_id ASC ")
    employees = cursor.fetchall()
    cursor.execute(
        "SELECT * FROM department WHERE department_id != 'NONE' ORDER BY department_id ASC"
    )
    departments = cursor.fetchall()
    return render_template('admin/employees.html',
                           employees=employees,
                           departments=departments,
                           title="Employees",
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 4
0
def comment():
    if (get_username() == ""):
        flash ("Please Login!")
        return redirect(url_for('auth.login'))
    username = get_username()
    form = commentFormLower()
    cursor.execute("SELECT * FROM leave_application WHERE employee_id = %s ORDER BY leave_id DESC", (username,))
    leave = cursor.fetchone()
    cursor.execute("SELECT * FROM comments ORDER BY leave_id DESC")
    comments = cursor.fetchall()
    if leave:
        if leave[6] == "Sent Back":
            if form.validate_on_submit():
                comment = form.comment.data
                comment_by = username
                comment_time = str(datetime.datetime.now())
                cursor.execute("UPDATE leave_Application SET status = %s WHERE leave_id = (%s)", ("Waiting", leave[0]))
                cursor.execute("SELECT role FROM comments WHERE leave_id = %s ORDER BY comment_id DESC", (leave[0],))
                end_route = cursor.fetchone()[0]
                cursor.execute("SELECT department_id FROM employee WHERE employee_id = %s", (username,))
                department_id = cursor.fetchone()[0]
                cursor.execute("INSERT INTO leave_requests(role, leave_id, department_id) VALUES(%s, %s, %s)", (end_route, leave[0], department_id))
                cursor.execute("INSERT INTO comments(leave_id, comment, comment_time, comment_by, role, department_id) VALUES(%s, %s, %s, %s, %s, %s)", (leave[0], comment, comment_time, comment_by, get_role(), department_id))
                conn.commit()
                flash ('Application Re-sent!')
                return  redirect(url_for('user.dashboard', username = username))
            return render_template('user/leaves/comment.html', form = form, leave = leave, comments = comments, title = "Comment", username = username, isadmin = get_isadmin(), role = get_role())
        flash ('No action required!')
        return  redirect(url_for('user.dashboard', username = username))
    flash ('No action required!')
    return  redirect(url_for('user.dashboard', username = username))
Esempio n. 5
0
def list_positions():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute("SELECT * FROM pos ORDER BY position ASC;")
    positions = cursor.fetchall()
    return render_template('admin/positions/positions.html',
                           positions=positions,
                           title="Positions",
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 6
0
def list_hod():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute("SELECT * FROM hod ORDER BY department_id ASC")
    hods = cursor.fetchall()
    return render_template('admin/roles/hod.html',
                           hods=hods,
                           title='HOD',
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 7
0
def list_ccf():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute("SELECT * FROM ccf ORDER BY position ASC")
    poss = cursor.fetchall()
    return render_template('admin/roles/ccf.html',
                           poss=poss,
                           title='CCF',
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 8
0
def list_routes():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute("SELECT * FROM route ORDER BY role")
    routes = cursor.fetchall()
    return render_template('admin/route/route.html',
                           routes=routes,
                           title="Routes",
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 9
0
def leave_requests():
    if (get_username() == ""):
        flash ("Please Login!")
        return redirect(url_for('auth.login'))
    username = get_username()
    cursor.execute("SELECT leave_application.leave_id, leave_type, leave_application.employee_id, applied_date, start_date, end_date, status, application, leave_application.department_id FROM leave_application, leave_requests WHERE leave_requests.role = %s and leave_application.leave_id = leave_requests.leave_id", (get_role(),))
    temp_requests = cursor.fetchall()
    requests = []
    if get_role() == 'HOD':
        cursor.execute("SELECT department_id FROM employee WHERE employee_id = %s", (username,))
        department_id = cursor.fetchone()[0]
        for request in temp_requests:
            if department_id == request[8]:
                requests.append(request)
    else :
        requests = temp_requests
    cursor.execute("SELECT * FROM comments ORDER BY leave_id DESC")
    comments = cursor.fetchall()
    return render_template('user/leaves/leave_requests.html', requests = requests, comments = comments, title="Leave Requests", username = username, isadmin = get_isadmin(), role = get_role())
Esempio n. 10
0
def list_departments():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    cursor.execute(
        "SELECT * FROM department WHERE department_id != 'NONE' ORDER BY department_id ASC;"
    )
    departments = cursor.fetchall()
    return render_template('admin/departments/departments.html',
                           departments=departments,
                           title="Departments",
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 11
0
def history_ccf():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    hod = False
    cursor.execute(
        "SELECT * FROM ccf_history ORDER BY position ASC, start_date DESC, time ASC"
    )
    history = cursor.fetchall()
    return render_template('admin/history/history.html',
                           hod=hod,
                           history=history,
                           title="CCF History",
                           username=get_username(),
                           isadmin=get_isadmin())
Esempio n. 12
0
def history_hod():
    if get_isadmin() == False:
        return redirect(url_for('home.error403'))
    hod = True
    cursor.execute(
        "SELECT * FROM hod_history ORDER BY department_id ASC, start_date ASC, time ASC"
    )
    history = cursor.fetchall()
    return render_template('admin/history/history.html',
                           hod=hod,
                           history=history,
                           title="HOD History",
                           username=get_username(),
                           isadmin=get_isadmin())