Example #1
0
def add_employee(usuario):
    if request.method == 'POST':
        print(usuario)
        # cpassword = None
        # personal = request.get_json()['ruc']
        # print(personal)
        ruc = request.get_json()['ruc']
        name = request.get_json()['nombre']
        lastname = request.get_json()['apellido']
        address = request.get_json()['direccion']
        email = request.get_json()['email']
        city = request.get_json()['city']
        numberphone = request.get_json()['telefono']
        birthday = request.get_json()['sfechaN']
        fingreso = request.get_json()['sfechaI']
        password = request.get_json()['password']
        cpassword = generate_password_hash(password, method='sha256')
        print(password, cpassword)
        cargo = request.get_json()['idcargo']
        isUsuario = request.get_json()['isUsuario']
        sex = request.get_json()['sexo']
        if isUsuario == True:
            esUsuario = '1'
        else:
            esUsuario = '0'
        today = time.strftime("%d-%m-%y")
        message = Personal.insert_employee(ruc, name, lastname, address, email,
                                           city, numberphone, birthday,
                                           fingreso, today, esUsuario,
                                           cpassword, cargo, sex, usuario)
        empl = Personal.get_personal()
        getData = Personal.datosFormateados(empl)
        return jsonify({"personal": getData})
Example #2
0
def update_employee(usuario):
    if request.method == 'PUT':
        id = request.get_json()['codigo']
        ruc = request.get_json()['ruc']
        name = request.get_json()['nombre']
        lastname = request.get_json()['apellido']
        address = request.get_json()['direccion']
        email = request.get_json()['email']
        city = request.get_json()['city']
        numberphone = request.get_json()['telefono']
        birthday = request.get_json()['sfechaN']
        # password = request.get_json()['password']
        cargo = request.get_json()['idcargo']
        isUsuario = request.get_json()['isUsuario']
        sex = request.get_json()['sexo']
        estado = request.get_json()['estado']
        if (estado):
            state = '1'
        else:
            state = '0'
        if (isUsuario):
            esUsuario = '1'
        else:
            esUsuario = '0'
    message = Personal.update_employee(id, ruc, name, lastname, address, email,
                                       city, numberphone, birthday, cargo, sex,
                                       esUsuario, state, usuario)
    print(message)
    empl = Personal.get_personal()
    getData = Personal.datosFormateados(empl)
    return jsonify({"personal": getData})
Example #3
0
def personal():
    empl = Personal.get_personal()
    getData = Personal.datosFormateados(empl)
    return jsonify({"personal": getData})