Example #1
0
def adminsaddentry():
    if current_user.usertype == 'admin':
        if request.method == 'POST':
            uid = request.form['uid']
            name = request.form['name']
            year = request.form['year']
            contact = request.form['contact']
            address = request.form['address']
            cutoff = request.form['cutoff']
            brdpoint = request.form['brdpoint']
            area = request.form['area']
            branch = request.form['branch']
            fathername = request.form['fathername']
            fatheroccupation = request.form['fatheroccupation']
            fathercontact = request.form['fathercontact']
            email = request.form['email']
            regno = request.form['regno']
            dob = '-'.join(request.form['dob'].split('-')[::-1])
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'insert into profile values ({uid},"{name}",{regno},"{dob}", "{address}", {contact}, "{email}","{brdpoint}", "{branch}", "{area}", "{fathername}", "{fatheroccupation}", {fathercontact}, {cutoff}, {year})'
            )

            db.commit()
            db.close()
            return redirect('/admin')
        else:
            return render_template('admin/saddentry.html')
    else:
        return redirect(url_for('main'))
Example #2
0
def subjectadd():
    if current_user.usertype == 'admin':
        if request.method == 'POST':
            sem = request.form['sem']
            subcode = request.form['subcode']
            subname = request.form['subname']
            branch = request.form['branch']
            staffid = request.form['staffid']
            year = request.form['year']
            section = request.form['section']
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'insert into subjects values({sem},"{subcode}","{subname}","{branch}","{staffid}",{year},"{section}")'
            )
            db.commit()
            db.close()
            return render_template('attendance/add.html',
                                   alert="Subject added successfully")
        else:
            if session['message']:
                alert = session['message']
                session['message'] = ''
            else:
                alert = ''
            return render_template('attendance/add.html', alert=alert)
Example #3
0
def admineditprofile():
    if current_user.usertype == 'admin':
        if request.method == 'POST':
            uid = request.form['uid']
            name = request.form['name']
            year = request.form['year']
            contact = request.form['contact']
            address = request.form['address']
            cutoff = request.form['cutoff']
            brdpoint = request.form['brdpoint']
            bloodgrp = request.form['bloodgrp']
            area = request.form['area']
            branch = request.form['branch']
            fathername = request.form['fathername']
            fatheroccupation = request.form['fatheroccupation']
            fathercontact = request.form['fathercontact']
            email = request.form['email']
            regno = request.form['regno']
            dob = '-'.join(request.form['dob'].split('-')[::-1])
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute('select * from profile')
            print(
                f'update profile set name = "{name}", regno = {regno}, dob = "{dob}", address = "{address}", contact = {contact},email = "{email}",brdpoint = "{brdpoint}", branch = "{branch}",area = "{area}",fathername = "{fathername}",fatheroccupation="{fatheroccupation}",fathercontact={fathercontact}, cutoff={cutoff}, year={year} where id = {uid}'
            )
            cursor.execute(
                f'update profile set name = "{name}", regno = {regno}, dob = "{dob}", bloodgrp = "{bloodgrp}", address = "{address}", contact = {contact},email = "{email}",brdpoint = "{brdpoint}", branch = "{branch}",area = "{area}",fathername = "{fathername}",fatheroccupation="{fatheroccupation}",fathercontact={fathercontact}, cutoff={cutoff}, year={year} where id = {uid}'
            )
            db.commit()
            db.close()
            return redirect(url_for('adminsprofilemain'))
Example #4
0
def staff_materials():
    if current_user.usertype == 'staff':
        if request.method == 'POST':
            upfile = request.files['filename']
            branch = request.form['branch']
            sem = request.form['sem']
            subject = request.form['subject']
            mtype = request.form['mtype']
            captions = request.form['captions']
            import os
            upfile.save("./erp/sts/materials/" + upfile.filename)
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'select code from subjects where name like "{subject}"')
            subject = cursor.fetchall()[0][0]
            cursor.execute(
                f'insert into materials values ( "{branch}", "{sem}", "{subject}", "{upfile.filename}", "xyz", "{mtype}", "{captions}")'
            )
            db.commit()
            db.close()
            session['message'] = 'Uploaded Successfully'
            return redirect(url_for('staff_materials'))
        else:
            try:
                print(session['message'])
                if session['message']:
                    alertmessage = session['message']
                    session['message'] = ''
                else:
                    alertmessage = ''
            except:
                alertmessage = ''
            print(alertmessage)
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'select * from subjects where staffid like "{current_user.uid}"'
            )
            data = cursor.fetchall()
            cursor.execute(
                f'select branch from subjects where staffid like "{current_user.uid}" group by branch'
            )
            secdata = cursor.fetchall()
            print(data)
            db.close()
            return render_template('staff/materials.html',
                                   data=data,
                                   secdata=secdata,
                                   alertmessage=alertmessage)
Example #5
0
def profile():
    db = pymysql.connect('localhost',
                         password='******',
                         db='erp',
                         user='******')
    cursor = db.cursor()
    cursor.execute(f'select * from profile where id={current_user.uid}')
    data = cursor.fetchall()[0]
    db.close()
    return render_template('profile.html', data=data)
Example #6
0
def circular():
    db = pymysql.connect('localhost',
                         password='******',
                         db='erp',
                         user='******')
    cursor = db.cursor()
    cursor.execute('select * from circular')
    data = cursor.fetchall()
    db.close()
    return render_template('circular.html', data=data)
Example #7
0
def adminviewprofile():
    if current_user.usertype == 'admin':
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(f'select * from profile')
        db.close()
        data = cursor.fetchall()
        return render_template('admin/viewprofile.html', data=data)
    else:
        return redirect(url_for('main'))
Example #8
0
def deletestudent(studentid):
    if current_user.usertype == 'admin':
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(f'delete from profile where id={studentid}')
        db.commit()
        db.close()
        return redirect(url_for('adminsprofilemain'))
    else:
        pass
Example #9
0
def staff_home():
    if current_user.usertype == 'staff':
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(
            f'select name, branch, year, sem, code from subjects where staffid like "{current_user.uid}"'
        )
        data = cursor.fetchall()
        print(data)
        db.close()
        return render_template('staff/staff_h_page.html', i=data)
    else:
        return redirect(url_for('main'))
Example #10
0
def subjects():
    if not request.args:
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(
            f'select sem, name from subjects where branch like (select branch from profile where id = {current_user.uid})'
        )
        data = cursor.fetchall()
        # ((1,"sci"),(2,"poi"))
        subject = {}
        for i in data:
            if i[0] in subject:
                subject[i[0]].append(i[1])
            else:
                subject[i[0]] = [0, i[1]]
        print(subject)
        print("\n\n\n\n\\n\n\n\n\n\n\n\\n\nn\n", data)
        cursor.execute(
            f'select * from materials where branch like (select branch from profile where id = {current_user.uid})'
        )
        print('\n\n\n\n\n\\n\n\n\n', subject)
        materials = cursor.fetchall()
        db.close()
        return render_template('subjects.html',
                               subject=subject,
                               materials=materials)
    else:
        subject = request.args.get('subjects')
        type = request.args.get('material')
        sem = request.args.get('sem')
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(
            f'select name, captions, filename from materials where branch like (select branch from profile where id = {current_user.uid}) and subject like (select code from subjects where name like "{subject}") and type like "{type}"'
        )
        data = cursor.fetchall()
        return render_template("materials.html", data=data, type=type)
Example #11
0
def main():
    session['message'] = ''
    if current_user.usertype == 'student':
        db = pymysql.connect('localhost',
                             password='******',
                             db='erp',
                             user='******')
        cursor = db.cursor()
        cursor.execute(f'select * from profile where id={current_user.uid}')
        data = cursor.fetchall()[0]
        db.close()
        return render_template('main.html', data=data)
    elif current_user.usertype == 'admin':
        return redirect(url_for('admin'))
    elif current_user.usertype == 'account':
        return redirect(url_for('accountspage'))
    elif current_user.usertype == 'staff':
        return redirect(url_for('staff_home'))
    else:
        return redirect('/attendance/mark')
Example #12
0
def subjectedit():
    if current_user.usertype == 'admin':
        if request.method == 'POST':
            try:
                subname = request.form['subname']
            except:
                subname = None
            if subname:
                xyz = request.form
                sem = request.form['sem']
                subcode = request.form['subcode']
                branch = request.form['branch']
                staffid = request.form['staffid']
                year = request.form['year']
                section = request.form['section']
                db = pymysql.connect('localhost',
                                     password='******',
                                     db='erp',
                                     user='******')
                cursor = db.cursor()
                cursor.execute(
                    f'update subjects set sem = {sem},year = "{year}", section = "{section}", branch = "{branch}", staffid = "{staffid}", name = "{subname}" where code = "{subcode}"'
                )
                db.commit()
                db.close()
                session['message'] = 'Edited Successfully'
                return redirect('/subject/add')
            else:
                subcode = request.form['subcode']
                print(subcode)
                db = pymysql.connect('localhost',
                                     password='******',
                                     db='erp',
                                     user='******')
                cursor = db.cursor()
                cursor.execute(
                    f'select * from subjects where code = "{subcode}"')
                data = cursor.fetchall()[0]
                return render_template('attendance/edit.html', data=data)
        else:
            return render_template()
Example #13
0
def staff_marks2():
    if current_user.usertype == 'staff':
        if request.method == 'POST':

            data = dict(request.form)
            print(markdata.values)
            for i in data.keys():
                markdata.values[str(i)]['sem' + str(session['sem'])][''.join(
                    session['testname'].lower().split())]['marks'].append(
                        data[i])
                markdata.values[str(i)]['sem' +
                                        str(session['sem'])]['sub'].append(
                                            session['subject'])
                markdata.commit()
            session.pop("sem", None)
            session.pop("testname", None)
            session.pop("branch", None)
            session.pop("subject", None)
            session.pop("sec", None)
            return redirect(url_for('main'))
        else:
            sec = session['sec']
            testname = session['testname']
            branch = session['branch']
            subject = session['subject']
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'select id, name from profile where section like "{sec}" and branch like "{branch}"'
            )
            data = cursor.fetchall()
            cursor.execute(
                f'select sem from subjects where code like "{subject}"')
            session['sem'] = cursor.fetchall()[0][0]
            db.close()
            return render_template('staff/marks_2.html', data=data)
Example #14
0
def staff_attendance_mark():
    if current_user.usertype == 'staff':
        if request.method == 'POST':
            book = load_workbook(path)
            writer = pd.ExcelWriter(path, engine='openpyxl')
            writer.book = book
            try:
                df = pd.read_excel(path, sheet_name=session['date'])
            except:
                df = pd.read_excel(path, sheet_name='template')
            attendance = {}
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'select id from profile where branch = \'{session["branch"]}\' and year = {session["year"]} and section like \'{session["sec"]}\''
            )
            for i in cursor.fetchall():
                for j in df.values:
                    if i[0] in j:
                        tempvar = True
                        break
                else:
                    tempvar = False
                if tempvar:
                    pass
                else:
                    df = df.append(
                        {
                            'sid': i[0],
                            'session1': 'p',
                            'session2': 'p',
                            'session3': 'p',
                            'session4': 'p',
                            'session5': 'p',
                            'overall': 'p'
                        },
                        ignore_index=True,
                    )
            cdata = request.form
            for i in cdata:
                temp = i.split('-')
                attendance[int(temp[1])] = temp[0][0]
            print(attendance)
            for i in attendance.keys():
                df.loc[df['sid'] == i, [session['session']]] = attendance[i]

            print(df)
            writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
            df.to_excel(writer, sheet_name=session['date'], index=False)
            writer.save()
            writer.close()
            session['message'] = "Attendance Marked Sucessfully"
            db.close()
            return redirect(url_for('main'))
        else:
            db = pymysql.connect('localhost',
                                 password='******',
                                 db='erp',
                                 user='******')
            cursor = db.cursor()
            cursor.execute(
                f'select id,name from profile where branch = \'{session["branch"]}\' and year = \'{session["year"]}\' and section = \'{session["sec"]}\''
            )
            data = cursor.fetchall()
            print(data)
            db.close()
            return render_template('staff/markAttendance.html',
                                   data=data,
                                   len=len)