forked from elmau/empresa-libre
Set branch by user
This commit is contained in:
parent
0957cf673f
commit
7fc1d42381
|
@ -3482,6 +3482,15 @@ class Sucursales(BaseModel):
|
||||||
)
|
)
|
||||||
return tuple(rows)
|
return tuple(rows)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_for_select(cls, args):
|
||||||
|
fields = (
|
||||||
|
Sucursales.id,
|
||||||
|
Sucursales.nombre.alias('value')
|
||||||
|
)
|
||||||
|
rows = Sucursales.select(*fields).dicts()
|
||||||
|
return tuple(rows)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_there_are_branchs(cls, args):
|
def _get_there_are_branchs(cls, args):
|
||||||
result = bool(Sucursales.select().count())
|
result = bool(Sucursales.select().count())
|
||||||
|
@ -3573,6 +3582,19 @@ class Usuarios(BaseModel):
|
||||||
response = {'ok': result}
|
response = {'ok': result}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _set_branch(cls, args, user):
|
||||||
|
id = args['id_user']
|
||||||
|
values = {'sucursal': args['id_branch']}
|
||||||
|
where = (Usuarios.id == id)
|
||||||
|
q = (Usuarios
|
||||||
|
.update(**values)
|
||||||
|
.where(where)
|
||||||
|
)
|
||||||
|
result = bool(q.execute())
|
||||||
|
response = {'ok': result}
|
||||||
|
return response
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def post(cls, values, user):
|
def post(cls, values, user):
|
||||||
opt = values['opt']
|
opt = values['opt']
|
||||||
|
|
|
@ -2061,7 +2061,10 @@ function set_user_branch(id, state){
|
||||||
if(state){
|
if(state){
|
||||||
win_set_branch_user.init()
|
win_set_branch_user.init()
|
||||||
$$('txt_user_id').setValue(id)
|
$$('txt_user_id').setValue(id)
|
||||||
//~ $$('txt_user_name').setValue(id)
|
webix.ajax().get('/sucursales?opt=for_select', function(text, data){
|
||||||
|
var values = data.json()
|
||||||
|
$$('lst_branchs').getList().parse(values)
|
||||||
|
})
|
||||||
$$('win_set_branch_user').show()
|
$$('win_set_branch_user').show()
|
||||||
}else{
|
}else{
|
||||||
var args = {
|
var args = {
|
||||||
|
@ -2088,7 +2091,28 @@ function set_user_branch(id, state){
|
||||||
|
|
||||||
|
|
||||||
function cmd_set_branch_user_save_click(){
|
function cmd_set_branch_user_save_click(){
|
||||||
|
var id_user = $$('txt_user_id').getValue()
|
||||||
|
var id_branch = $$('lst_branchs').getValue()
|
||||||
|
$$('win_set_branch_user').hide()
|
||||||
|
|
||||||
|
var args = {
|
||||||
|
opt: 'set_branch',
|
||||||
|
values: {id_user: id_user, id_branch: id_branch}
|
||||||
|
}
|
||||||
|
webix.ajax().post('/users', args, {
|
||||||
|
error:function(text, data, XmlHttpRequest){
|
||||||
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success:function(text, data, XmlHttpRequest){
|
||||||
|
var values = data.json()
|
||||||
|
if(values.ok){
|
||||||
|
msg_ok('Asignación de Sucursal establecida correctamente')
|
||||||
|
}else{
|
||||||
|
msg_error(values.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue