diff --git a/source/app/controllers/main.py b/source/app/controllers/main.py
index a342572..4192e3b 100644
--- a/source/app/controllers/main.py
+++ b/source/app/controllers/main.py
@@ -150,6 +150,8 @@ class AppValues(object):
req.context['result'] = self._db.importar_bdfl()
elif table == 'invoicenotes':
req.context['result'] = self._db.save_invoice_notes(values)
+ elif table == 'nivedu':
+ req.context['result'] = self._db.add_nivel_educativo(values)
else:
req.context['result'] = self._db.validate_cert(values, session)
else:
diff --git a/source/app/models/db.py b/source/app/models/db.py
index ad8f47c..98fce0d 100644
--- a/source/app/models/db.py
+++ b/source/app/models/db.py
@@ -25,6 +25,12 @@ class StorageEngine(object):
return getattr(self, '_get_{}'.format(table))(values, session)
return getattr(self, '_get_{}'.format(table))(values)
+ def _get_nivedusat(self, values):
+ return main.SATNivelesEducativos.get_by()
+
+ def _get_niveduall(self, values):
+ return main.NivelesEducativos.get_all()
+
def _get_titlelogin(self, values):
return main.get_title_app(2)
@@ -244,6 +250,8 @@ class StorageEngine(object):
return main.Usuarios.remove(id)
if table == 'config':
return main.Configuracion.remove(id)
+ if table == 'nivedu':
+ return main.NivelesEducativos.remove(id)
return False
def _get_client(self, values):
@@ -338,6 +346,9 @@ class StorageEngine(object):
def add_folios(self, values):
return main.Folios.add(values)
+ def add_nivel_educativo(self, values):
+ return main.NivelesEducativos.add(values)
+
def get_doc(self, type_doc, id, rfc):
return main.get_doc(type_doc, id, rfc)
diff --git a/source/app/models/main.py b/source/app/models/main.py
index 74d6bbd..136ffb3 100644
--- a/source/app/models/main.py
+++ b/source/app/models/main.py
@@ -1401,6 +1401,12 @@ class SATNivelesEducativos(BaseModel):
def __str__(self):
return self.name
+ @classmethod
+ def get_by(cls):
+ rows = SATNivelesEducativos.select(
+ SATNivelesEducativos.name).tuples()
+ return tuple([r[0] for r in rows])
+
class NivelesEducativos(BaseModel):
nombre = TextField()
@@ -1415,6 +1421,26 @@ class NivelesEducativos(BaseModel):
def __str__(self):
return '{} ({})'.format(self.nombre, self.autorizacion)
+ @classmethod
+ def get_all(cls):
+ rows = NivelesEducativos.select().dicts()
+ return tuple(rows)
+
+ @classmethod
+ def add(cls, values):
+ try:
+ NivelesEducativos.create(**values)
+ result = {'ok': True}
+ except IntegrityError:
+ msg = 'Nivel Educativo existente'
+ result = {'ok': False, 'msg': msg}
+ return result
+
+ @classmethod
+ def remove(cls, id):
+ q = NivelesEducativos.delete().where(NivelesEducativos.id==int(id))
+ return bool(q.execute())
+
class Grupos(BaseModel):
nivel = ForeignKeyField(NivelesEducativos)
diff --git a/source/static/js/controller/admin.js b/source/static/js/controller/admin.js
index b7a4ea5..5e8fa9c 100644
--- a/source/static/js/controller/admin.js
+++ b/source/static/js/controller/admin.js
@@ -23,6 +23,7 @@ var controllers = {
$$('emisor_logo').attachEvent('onItemClick', emisor_logo_click)
$$('cmd_emisor_agregar_cuenta').attachEvent('onItemClick', cmd_emisor_agregar_cuenta_click)
$$('cmd_emisor_eliminar_cuenta').attachEvent('onItemClick', cmd_emisor_eliminar_cuenta_click)
+ $$('cmd_niveles_educativos').attachEvent('onItemClick', cmd_niveles_educativos_click)
$$('emisor_cuenta_saldo_inicial').attachEvent('onChange', emisor_cuenta_saldo_inicial_change)
//~ SAT
tb_sat = $$('tab_sat').getTabbar()
@@ -479,9 +480,9 @@ function emisor_postal_code_key_press(code, e){
function chk_escuela_change(new_value, old_value){
var value = Boolean(new_value)
if (value){
- $$('cmd_niveles').enable()
+ $$('cmd_niveles_educativos').enable()
} else {
- $$('cmd_niveles').disable()
+ $$('cmd_niveles_educativos').disable()
}
}
@@ -1836,3 +1837,90 @@ function txt_ticket_printer_key_press(code, e){
})
}
+
+
+function cmd_niveles_educativos_click(){
+ admin_ui_niveles_educativos.init()
+ $$('win_niveles_educativos').show()
+ get_niveles_educativos()
+}
+
+
+function get_niveles_educativos(){
+ webix.ajax().sync().get('/values/niveduall', {
+ 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()
+ $$('grid_niveles_educativos').clearAll()
+ $$('grid_niveles_educativos').parse(values)
+ $$('grid_niveles_educativos').refresh()
+ }
+ })
+}
+
+
+function add_nivel_educativo_click(){
+ var form = $$('form_niveles_educativos')
+
+ if (!form.validate()){
+ msg = 'Valores inválidos'
+ msg_error(msg)
+ return
+ }
+
+ var values = form.getValues()
+
+ webix.ajax().post('/values/nivedu', values, {
+ error:function(text, data, XmlHttpRequest){
+ msg = 'Ocurrio un error, consulta a soporte técnico'
+ msg_error(msg)
+ },
+ success:function(text, data, XmlHttpRequest){
+ var result = data.json()
+ form.setValues({})
+ if(result.ok){
+ $$('grid_niveles_educativos').add(values)
+ }else{
+ msg_error(result.msg)
+ }
+ }
+ })
+
+}
+
+
+function delete_nivel_educativo(id){
+ webix.ajax().del('/values/nivedu', {id: id}, function(text, xml, xhr){
+ if(xhr.status == 200){
+ $$('grid_niveles_educativos').remove(id)
+ }else{
+ msg = 'No se pudo eliminar'
+ msg_error(msg)
+ }
+ })
+}
+
+
+function grid_niveles_educativos_click(id){
+ if(id.column != 'delete'){
+ return
+ }
+
+ msg = '¿Estás seguro de eliminar este Nivel Educativo'
+ webix.confirm({
+ title: 'Eliminar',
+ ok: 'Si',
+ cancel: 'No',
+ type: 'confirm-error',
+ text: msg,
+ callback:function(result){
+ if(result){
+ delete_nivel_educativo(id.row)
+ }
+ }
+ })
+
+}
\ No newline at end of file
diff --git a/source/static/js/ui/admin.js b/source/static/js/ui/admin.js
index e5d454f..76b5f75 100644
--- a/source/static/js/ui/admin.js
+++ b/source/static/js/ui/admin.js
@@ -48,6 +48,72 @@ var admin_ui_windows = {
}
+var grid_cols_niveles_educativos = [
+ {id: 'id', header: 'ID', hidden: true},
+ {id: 'delete', header: '', width: 30, css: 'delete'},
+ {id: 'nombre', header: 'Nivel', fillspace: 1},
+ {id: 'autorizacion', header: 'Autorización', fillspace: 1},
+]
+
+
+var grid_niveles_educativos = {
+ view: 'datatable',
+ id: 'grid_niveles_educativos',
+ select: 'cell',
+ adjust: true,
+ autoheight: true,
+ headermenu: true,
+ columns: grid_cols_niveles_educativos,
+ on:{
+ 'data->onStoreUpdated':function(){
+ this.data.each(function(obj, i){
+ obj.delete = '-'
+ })
+ }
+ },
+}
+
+
+var form_controls_niveles_educativos = [
+ {cols: [
+ {view: 'text', id: 'txt_nivel_educativo', label: 'Nivel', suggest: '/values/nivedusat',
+ labelPosition: 'top', name: 'nombre', required: true},
+ {view: "text", id: 'txt_auth_rvoe', label: 'Autorización',
+ name: 'autorizacion', labelPosition: 'top'},
+ {view: 'button', type: 'iconTop', icon: 'plus', label: 'Agregar',
+ autowidth: true, click: function(){
+ add_nivel_educativo_click()
+ }}
+ ]},
+ grid_niveles_educativos,
+ {},
+ {cols:[{},
+ {view: "button", value: 'Cerrar', click: "$$('win_niveles_educativos').close()"},
+ {}]}
+]
+
+
+var admin_ui_niveles_educativos = {
+ init: function(){
+ webix.ui({
+ view: 'window',
+ id: 'win_niveles_educativos',
+ head: 'Niveles Educativos',
+ width: 500,
+ modal: true,
+ position: 'center',
+ body: {
+ view: 'form', id: 'form_niveles_educativos',
+ elements: form_controls_niveles_educativos
+ }
+ })
+
+ $$('grid_niveles_educativos').attachEvent('onItemClick', grid_niveles_educativos_click)
+
+ },
+}
+
+
var menu_data = [
{id: 'app_home', icon: 'dashboard', value: 'Inicio'},
{id: 'app_emisor', icon: 'user-circle', value: 'Emisor'},
@@ -129,7 +195,7 @@ var emisor_otros_datos= [
{template: 'Escuela', type: 'section'},
{cols: [{view: 'checkbox', id: 'chk_escuela', name: 'es_escuela',
label: 'Es Escuela'},
- {view: 'button', id: 'cmd_niveles', label: 'Niveles Escolares',
+ {view: 'button', id: 'cmd_niveles_educativos', label: 'Niveles Educativos',
type: 'form', align: 'center', autowidth: true, disabled: true},
{}, {}]},
{template: 'ONG', type: 'section'},
diff --git a/source/xslt/cadena.xslt b/source/xslt/cadena.xslt
index be01a88..8ed4715 100644
--- a/source/xslt/cadena.xslt
+++ b/source/xslt/cadena.xslt
@@ -11,6 +11,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+