def newemployee(): if request.method=="POST": empid=request.form['empid'] cur_city = request.form['cur_city'] name = request.form['full_name'] desig = request.form['designation'] bgroup = request.form['blood_group'] dob = request.form['dob'] cur_address = request.form['cur_address'] phone = request.form['phone'] privel = request.form['privel'] cur_state = request.form['cur_state'] ephone=request.form['ephone'] email = request.form['email'] joining = request.form['joining'] cur=con.cursor() try: cur.execute("insert into emp_details values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",(empid,name,email,phone,ephone,dob,privel,desig,bgroup,joining,cur_address,cur_city,cur_state)) con.commit() p="Form successfully submitted" fmt="success" e="success" cur.close() data_t = (session["name"], session["type"], p, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt) except Exception, e: p = e fmt = "danger" data_t = (session["name"], session["type"], e, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt)
def newemployee(): r = ifsessionisset() if r == 1: if request.method == "POST": empid = request.form['empid'] cur_city = request.form['cur_city'] name = request.form['full_name'] desig = request.form['designation'] bgroup = request.form['blood_group'] dob = request.form['dob'] cur_address = request.form['cur_address'] phone = request.form['phone'] privel = request.form['privel'] cur_state = request.form['cur_state'] ephone = request.form['ephone'] email = request.form['email'] joining = request.form['joining'] try: cur = con.cursor() cur.execute( "insert into emp_details values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", (empid, name, email, phone, ephone, dob, privel, desig, bgroup, joining, cur_address, cur_city, cur_state)) password = name.split()[0] con.commit() cur = con.cursor() cur.execute( "insert into emp_login (id,username,name,password,type) values(%s,%s,%s,%s,%s) ", [ empid, email, name, hashlib.sha1(password).hexdigest(), privel ]) con.commit() p = "Form successfully submitted. Username: "******" Password: "******" All the best to " + name fmt = "success" e = "success" cur.close() print(p) data_t = (session["name"], session["type"], p, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt) except Exception, e: p = e fmt = "danger" data_t = (session["name"], session["type"], p, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt) else: data_t = (session["name"], session["type"], None, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t)
def admin_att(): r = ifsessionisset() if r == 1: data_t = (session["name"], session["type"], None, af.get_emp_list(con)) if request.method == "POST": to = request.form['adminto'] frm = request.form['adminfrom'] if to != "" and frm != "" and af.validate_date( to) and af.validate_date(frm): att_detail, path = af.get_col_att(to, frm, con) return render_template('admin_att.html', data_t=data_t, id=session["id"], to=to, frm=frm, d=att_detail, path=path) else: return render_template('admin_att.html', data_t=data_t, id=session["id"], to="", frm="", msg=null_msg) else: return render_template('admin_att.html', data_t=data_t, id=session["id"], to="", frm="") else: flash(login_msg) return render_template('hello.html')
def emp_view(): r = ifsessionisset() if (r == 1): data_t = (session["name"], session["type"], None, af.get_emp_list(con)) emp_details = af.getempdetails(con) return render_template('emp_view.html', data_t=data_t, e=emp_details) else: flash(login_msg) return render_template('hello.html')
def request_at(): r = ifsessionisset() if r == 1: data_t = (session["name"], session["type"], None, af.get_emp_list(con)) return render_template('request_at.html', data_t=data_t, id=session["id"]) else: flash(login_msg) return render_template('hello.html')
def view(): r = ifsessionisset() if r == 1: data_t = (session["name"], session["type"], None, af.get_emp_list(con)) if request.method == "POST": if request.form['to'] != "" and request.form['from'] != "": to = request.form['to'] frm = request.form['from'] if to != "" and frm != "" and af.validate_date( to) and af.validate_date(frm): if "ssid" in request.form: att_detail = af.getdateobj(to, frm, request.form["ssid"], con) return render_template('view.html', data_t=data_t, id=session["id"], to=to, frm=frm, d=att_detail) elif "empatt" in request.form: att_detail = af.getdateobj(to, frm, session["id"], con) return render_template('view.html', data_t=data_t, id=session["id"], to=to, frm=frm, d=att_detail) else: return render_template('view.html', data_t=data_t, id=session["id"], to="", frm="", msg="Format: YYYY-MM-DD") else: return render_template('view.html', data_t=data_t, id=session["id"], to="", frm="", msg=null_msg) else: return render_template('view.html', data_t=data_t, id=session["id"], to="", frm="") else: flash(login_msg) return render_template('hello.html')
def admin_att(): data_t = (session["name"], session["type"],None,af.get_emp_list(con)) if request.method=="POST": to = request.form['adminto'] frm = request.form['adminfrom'] if to!="" and frm!="": att_detail,path=af.get_col_att(to,frm,con) return render_template('admin_att.html', data_t=data_t, id=session["id"], to=to, frm=frm,d=att_detail,path=path) else: return render_template('admin_att.html', data_t=data_t, id=session["id"], to="", frm="") else: return render_template('admin_att.html',data_t=data_t,id=session["id"],to="",frm="")
def add_status(): emp_details = af.getempdetails("*", con) if request.method == "POST": if request.form["status"] != "": reply = af.set_status(session["id"], request.form["status"], con) return redirect(url_for("index")) else: status = "Sometimes I left blanks in life and blank status" reply = af.set_status(session["id"], status, con) return redirect(url_for("index")) data_t = (session["name"], session["type"], None, af.get_emp_list(con)) return render_template("add_status.html", data_t=data_t)
def view(): data_t = (session["name"], session["type"],None,af.get_emp_list(con)) if request.method=="POST": to = request.form['to'] frm = request.form['from'] if to!="" and frm!="": if "ssid" in request.form: att_detail = af.getdateobj(to, frm, request.form["ssid"], con) return render_template('view.html', data_t=data_t, id=session["id"], to=to, frm=frm, d=att_detail) elif "empatt" in request.form: att_detail=af.getdateobj(to,frm,session["id"],con) return render_template('view.html',data_t=data_t , id=session["id"], to=to, frm=frm,d=att_detail) else: return render_template('view.html',data_t=data_t,id=session["id"],to="",frm="")
def changepass(): if request.method == "POST": if request.form['oldpass'] != "" and request.form[ 'newpass1'] != "" and request.form['newpass2'] != "": oldpass = request.form['oldpass'] newpass1 = request.form['newpass1'] newpass2 = request.form['newpass2'] if newpass1 == newpass2: oldpassword = af.get_password(session['id'], con) if hashlib.sha1(oldpass).hexdigest( ) == oldpassword[0] and oldpassword is not None: result = af.set_newpassword( session['id'], hashlib.sha1(newpass1).hexdigest(), con) if result == "success": data_t = (session["name"], session["type"], "**Password successfully modified!", af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t) else: data_t = (session["name"], session["type"], result, af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t) else: data_t = (session["name"], session["type"], "**Remember old password or try forgot password", af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t) else: data_t = (session["name"], session["type"], "**New Password not match", af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t) else: data_t = (session["name"], session["type"], "**All fields are required", af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t) data_t = (session["name"], session["type"], None, af.get_emp_list(con)) return render_template('changepass.html', data_t=data_t)
def emp_view(): data_t = (session["name"], session["type"],None,af.get_emp_list(con)) emp_details=af.getempdetails(con) return render_template('emp_view.html',data_t=data_t,e=emp_details)
def request_at(): data_t = (session["name"], session["type"],None,af.get_emp_list(con)) return render_template('request_at.html', data_t=data_t, id=session["id"])
p="Form successfully submitted" fmt="success" e="success" cur.close() data_t = (session["name"], session["type"], p, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt) except Exception, e: p = e fmt = "danger" data_t = (session["name"], session["type"], e, af.get_emp_list(con)) return render_template('newemployee.html', data_t=data_t, fmt=fmt) else: data_t = (session["name"], session["type"], None, af.get_emp_list(con)) return render_template('newemployee.html',data_t=data_t) @app.route('/admin_att',methods=["POST","GET"]) def admin_att(): data_t = (session["name"], session["type"],None,af.get_emp_list(con)) if request.method=="POST": to = request.form['adminto'] frm = request.form['adminfrom'] if to!="" and frm!="": att_detail,path=af.get_col_att(to,frm,con) return render_template('admin_att.html', data_t=data_t, id=session["id"], to=to, frm=frm,d=att_detail,path=path) else: return render_template('admin_att.html', data_t=data_t, id=session["id"], to="", frm="")