forked from elmau/empresa-libre
Filtro por fechas en UI
This commit is contained in:
parent
82edc2a75a
commit
14ccf4fe1f
|
@ -32,6 +32,9 @@ class StorageEngine(object):
|
||||||
def send_email(self, values, session):
|
def send_email(self, values, session):
|
||||||
return main.Facturas.send(values['id'], session['rfc'])
|
return main.Facturas.send(values['id'], session['rfc'])
|
||||||
|
|
||||||
|
def _get_filteryears(self, values):
|
||||||
|
return main.Facturas.filter_years()
|
||||||
|
|
||||||
def _get_cert(self, values):
|
def _get_cert(self, values):
|
||||||
return main.Certificado.get_data()
|
return main.Certificado.get_data()
|
||||||
|
|
||||||
|
|
|
@ -1015,6 +1015,18 @@ class Facturas(BaseModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
order_by = ('fecha',)
|
order_by = ('fecha',)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def filter_years(cls):
|
||||||
|
data = [{'id': -1, 'value': 'Todos'}]
|
||||||
|
rows = (Facturas
|
||||||
|
.select(Facturas.fecha.year)
|
||||||
|
.group_by(Facturas.fecha.year)
|
||||||
|
.order_by(Facturas.fecha.year)
|
||||||
|
.scalar(as_tuple=True)
|
||||||
|
)
|
||||||
|
data += [{'id': int(row), 'value': int(row)} for row in rows]
|
||||||
|
return tuple(data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_xml(cls, id):
|
def get_xml(cls, id):
|
||||||
obj = Facturas.get(Facturas.id==id)
|
obj = Facturas.get(Facturas.id==id)
|
||||||
|
@ -1175,6 +1187,7 @@ class Facturas(BaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_(cls, values):
|
def get_(cls, values):
|
||||||
|
#~ print (values)
|
||||||
rows = tuple(Facturas
|
rows = tuple(Facturas
|
||||||
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
.select(Facturas.id, Facturas.serie, Facturas.folio, Facturas.uuid,
|
||||||
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
Facturas.fecha, Facturas.tipo_comprobante, Facturas.estatus,
|
||||||
|
|
|
@ -732,3 +732,18 @@ function cmd_invoice_cancelar_click(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function filter_year_change(nv, ov){
|
||||||
|
show(nv)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function filter_month_change(nv, ov){
|
||||||
|
show(nv)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function filter_dates_change(range){
|
||||||
|
show(range)
|
||||||
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ var controllers = {
|
||||||
$$('cmd_invoice_timbrar').attachEvent('onItemClick', cmd_invoice_timbrar_click)
|
$$('cmd_invoice_timbrar').attachEvent('onItemClick', cmd_invoice_timbrar_click)
|
||||||
$$('cmd_invoice_cancelar').attachEvent('onItemClick', cmd_invoice_cancelar_click)
|
$$('cmd_invoice_cancelar').attachEvent('onItemClick', cmd_invoice_cancelar_click)
|
||||||
$$('grid_invoices').attachEvent('onItemClick', grid_invoices_click)
|
$$('grid_invoices').attachEvent('onItemClick', grid_invoices_click)
|
||||||
|
$$('filter_year').attachEvent('onChange', filter_year_change)
|
||||||
|
$$('filter_month').attachEvent('onChange', filter_month_change)
|
||||||
|
$$('filter_dates').attachEvent('onChange', filter_dates_change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +96,14 @@ function get_products(){
|
||||||
|
|
||||||
|
|
||||||
function get_invoices(){
|
function get_invoices(){
|
||||||
|
var fy = $$('filter_year')
|
||||||
|
var fm = $$('filter_month')
|
||||||
|
|
||||||
|
var y = fy.getValue()
|
||||||
|
var m = fm.getValue()
|
||||||
|
|
||||||
var grid = $$('grid_invoices')
|
var grid = $$('grid_invoices')
|
||||||
webix.ajax().get('/invoices', {}, {
|
webix.ajax().get('/invoices', {'year': y, 'month': m}, {
|
||||||
error: function(text, data, xhr) {
|
error: function(text, data, xhr) {
|
||||||
webix.message({type: 'error', text: 'Error al consultar'})
|
webix.message({type: 'error', text: 'Error al consultar'})
|
||||||
},
|
},
|
||||||
|
@ -117,6 +126,26 @@ function menu_user_click(id, e, node){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function current_dates(){
|
||||||
|
var fy = $$('filter_year')
|
||||||
|
var fm = $$('filter_month')
|
||||||
|
var d = new Date()
|
||||||
|
|
||||||
|
fy.blockEvent()
|
||||||
|
fm.blockEvent()
|
||||||
|
|
||||||
|
fm.setValue(d.getMonth() + 1)
|
||||||
|
webix.ajax().sync().get('/values/filteryears', function(text, data){
|
||||||
|
var values = data.json()
|
||||||
|
fy.getList().parse(values)
|
||||||
|
fy.setValue(d.getFullYear())
|
||||||
|
})
|
||||||
|
|
||||||
|
fy.unblockEvent()
|
||||||
|
fm.unblockEvent()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function multi_change(prevID, nextID){
|
function multi_change(prevID, nextID){
|
||||||
//~ webix.message(nextID)
|
//~ webix.message(nextID)
|
||||||
if(nextID == 'app_partners'){
|
if(nextID == 'app_partners'){
|
||||||
|
@ -138,6 +167,7 @@ function multi_change(prevID, nextID){
|
||||||
if(nextID == 'app_invoices'){
|
if(nextID == 'app_invoices'){
|
||||||
active = $$('multi_invoices').getActiveId()
|
active = $$('multi_invoices').getActiveId()
|
||||||
if(active == 'invoices_home'){
|
if(active == 'invoices_home'){
|
||||||
|
current_dates()
|
||||||
get_invoices()
|
get_invoices()
|
||||||
}
|
}
|
||||||
gi = $$('grid_invoices')
|
gi = $$('grid_invoices')
|
||||||
|
|
|
@ -20,6 +20,33 @@ var toolbar_invoices_util = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
var months = [
|
||||||
|
{id: -1, value: 'Todos'},
|
||||||
|
{id: 1, value: 'Enero'},
|
||||||
|
{id: 2, value: 'Febrero'},
|
||||||
|
{id: 3, value: 'Marzo'},
|
||||||
|
{id: 4, value: 'Abril'},
|
||||||
|
{id: 5, value: 'Mayo'},
|
||||||
|
{id: 6, value: 'Junio'},
|
||||||
|
{id: 7, value: 'Julio'},
|
||||||
|
{id: 8, value: 'Agosto'},
|
||||||
|
{id: 9, value: 'Septiembre'},
|
||||||
|
{id: 10, value: 'Octubre'},
|
||||||
|
{id: 11, value: 'Noviembre'},
|
||||||
|
{id: 12, value: 'Diciembre'},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
var toolbar_invoices_filter = [
|
||||||
|
{view: 'richselect', id: 'filter_year', label: 'Año', labelAlign: 'right',
|
||||||
|
labelWidth: 50, width: 150, options: []},
|
||||||
|
{view: 'richselect', id: 'filter_month', label: 'Mes', labelAlign: 'right',
|
||||||
|
labelWidth: 50, width: 200, options: months},
|
||||||
|
{view: 'daterangepicker', id: 'filter_dates', label: 'Fechas',
|
||||||
|
labelAlign: 'right', width: 300},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
function get_icon(tipo){
|
function get_icon(tipo){
|
||||||
var node = "<img src='/static/img/file-" + tipo + ".png' height='20' width='17' style='margin: 5px 0px'/>"
|
var node = "<img src='/static/img/file-" + tipo + ".png' height='20' width='17' style='margin: 5px 0px'/>"
|
||||||
return node
|
return node
|
||||||
|
@ -34,7 +61,8 @@ var grid_invoices_cols = [
|
||||||
sort:"int", css: "cell_right"},
|
sort:"int", css: "cell_right"},
|
||||||
{id: "uuid", header: ["UUID", {content: "textFilter"}], adjust: "data",
|
{id: "uuid", header: ["UUID", {content: "textFilter"}], adjust: "data",
|
||||||
sort:"string", hidden:true},
|
sort:"string", hidden:true},
|
||||||
{id: "fecha", header: ["Fecha y Hora"], adjust: "data", sort:"string"},
|
{id: "fecha", header: ["Fecha y Hora"],
|
||||||
|
adjust: "data", sort:"date"},
|
||||||
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
|
{id: "tipo_comprobante", header: ["Tipo", {content: "selectFilter"}],
|
||||||
adjust: 'header', sort: 'string'},
|
adjust: 'header', sort: 'string'},
|
||||||
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
{id: "estatus", header: ["Estatus", {content: "selectFilter"}],
|
||||||
|
@ -316,6 +344,7 @@ var multi_invoices = {
|
||||||
{id: 'invoices_home', rows:[
|
{id: 'invoices_home', rows:[
|
||||||
{view: 'toolbar', elements: toolbar_invoices},
|
{view: 'toolbar', elements: toolbar_invoices},
|
||||||
{view: 'toolbar', elements: toolbar_invoices_util},
|
{view: 'toolbar', elements: toolbar_invoices_util},
|
||||||
|
{view: 'toolbar', elements: toolbar_invoices_filter},
|
||||||
grid_invoices,
|
grid_invoices,
|
||||||
]},
|
]},
|
||||||
{id: 'invoices_new', rows:[form_invoice, {}]}
|
{id: 'invoices_new', rows:[form_invoice, {}]}
|
||||||
|
|
|
@ -62,7 +62,8 @@ var ui_main = {
|
||||||
{view: 'label', label: 'Empresa Libre'},
|
{view: 'label', label: 'Empresa Libre'},
|
||||||
{},
|
{},
|
||||||
menu_user,
|
menu_user,
|
||||||
{view: 'button', type: 'icon', width: 45, css: 'app_button', icon: 'bell-o', badge: 1}
|
{view: 'button', type: 'icon', width: 45, css: 'app_button',
|
||||||
|
icon: 'bell-o', badge: 0}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue