Esempio n. 1
0
def editEmployee(id):
    jina_ya_emp = request.form['name']
    kra_pin = request.form['kra_pin']
    gender = request.form['gender']
    national_id = request.form['national_id']
    email = request.form['email']
    department_id = int(request.form['department'])
    basic_salary = request.form['basic_salary']
    benefits = request.form['benefits']

    if gender == "na":
        gender = None
    if department_id == "0":
        department_id = None

    EmployeesModel.update_by_id(id=id,
                                full_name=jina_ya_emp,
                                gender=gender,
                                kra_pin=kra_pin,
                                email=email,
                                national_id=national_id,
                                department_id=department_id,
                                basic_salary=basic_salary,
                                benefits=benefits)
    this_emp = EmployeesModel.fetch_by_id(id=id)
    this_dept = this_emp.department
    return redirect(url_for('employees', dept_id=this_dept.id))
Esempio n. 2
0
def editEmployee(pos):
    name = request.form['name']
    email = request.form['email']
    kra_pin = request.form['kra']
    basic_salary = request.form['basic']
    benefits = request.form['benefits']

    current_user =  EmployeesModel.fetch_by_id(pos)


    # use and to capture this error
    if EmployeesModel.check_kra(kra_pin) and kra_pin != current_user.kra_pin or EmployeesModel.check_email(email) and email != current_user.email:
        flash("Email/Kra already exists")
        return redirect(url_for('home'))



    EmployeesModel.update_by_id(id = pos,name=name,email = email,kra=kra_pin,
                                basic=basic_salary,benefits=benefits)


    return redirect(url_for('home'))
Esempio n. 3
0
def edit_employee(id):
    name = request.form['name']
    email = request.form['email']
    kra_pin = request.form['kra']
    basic_salary = request.form['basicsalary']
    benefits = request.form['benefits']

    current_user = EmployeesModel.fetch_by_id(id)

    if EmployeesModel.check_existing_kra(
            kra_pin
    ) and kra_pin != current_user.kra_pin or EmployeesModel.check_existing_email(
            email) and email != current_user.email:
        flash("Email/Kra Pin already exists")

    EmployeesModel.update_by_id(id=id,
                                name=name,
                                email=email,
                                kra=kra_pin,
                                salary=basic_salary,
                                benefits=benefits)
    return redirect(url_for('home'))
Esempio n. 4
0
def edit_employee(id):
    name = request.form['name']
    gender = request.form['gender']
    email = request.form['email']
    kra_pin = request.form['kra']
    basic_salary = request.form['basic']
    benefits = request.form['benefits']

    current_user = EmployeesModel.fetch_by_id(id)
    # use and to capture this error
    if EmployeesModel.check_kra_pin(kra_pin) and kra_pin != current_user.kra_pin or \
            EmployeesModel.check_email(email) and email != current_user.email:
        flash("Kra/email already exists")
        return redirect(url_for('home'))

    EmployeesModel.update_by_id(id=id,
                                name=name,
                                gender=gender,
                                email=email,
                                kra_pin=kra_pin,
                                basic_salary=basic_salary,
                                benefits=benefits)
    return redirect(url_for('home'))