added graphs in stock ledger and general ledger
This commit is contained in:
parent
52124cd637
commit
4dbbeaaedd
4 changed files with 62 additions and 23 deletions
4
js/core.min.js
vendored
4
js/core.min.js
vendored
|
|
@ -231,11 +231,11 @@ if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!(me.fields_by_name[df.pare
|
|||
*/
|
||||
wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('<div class="content"></div>').attr('id',"page-"+label).appendTo(this.container).get(0);if(onshow)
|
||||
$(page).bind('show',onshow);if(onshow)
|
||||
$(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){return;}
|
||||
$(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){$(this.page).trigger('show');return;}
|
||||
var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];}
|
||||
if(!page){console.log('Page not found '+label);return;}
|
||||
if(this.page&&this.page!=page){$(this.page).toggle(false);$(this.page).trigger('hide');}
|
||||
if(!this.page||this.page!=page){this.page=page;$(this.page).fadeIn();}
|
||||
if(!this.page||this.page!=page){this.page=page;$(this.page).toggle(true);}
|
||||
this.page._route=window.location.hash;document.title=this.page.label;$(this.page).trigger('show');scroll(0,0);return this.page;}});wn.views.add_module_btn=function(parent,module){$(parent).append(repl('<span class="label" style="margin-right: 8px; cursor: pointer;"\
|
||||
onclick="wn.set_route(\'%(module_small)s-home\')">\
|
||||
<i class="icon-home icon-white"></i> %(module)s Home\
|
||||
|
|
|
|||
|
|
@ -162,25 +162,32 @@ wn.datetime = {
|
|||
user_to_str: function(d) {
|
||||
var user_fmt = this.get_user_fmt();
|
||||
|
||||
var time_str = '';
|
||||
if (d.search(/ /)!=-1) {
|
||||
time_str = " " + d.split(" ")[1];
|
||||
d = d.split(" ")[0];
|
||||
}
|
||||
|
||||
if(user_fmt=='dd-mm-yyyy') {
|
||||
var d = d.split('-');
|
||||
return d[2]+'-'+d[1]+'-'+d[0];
|
||||
var val = d[2]+'-'+d[1]+'-'+d[0];
|
||||
}
|
||||
else if(user_fmt=='dd/mm/yyyy') {
|
||||
var d = d.split('/');
|
||||
return d[2]+'-'+d[1]+'-'+d[0];
|
||||
var val = d[2]+'-'+d[1]+'-'+d[0];
|
||||
}
|
||||
else if(user_fmt=='yyyy-mm-dd') {
|
||||
return d;
|
||||
var val = d;
|
||||
}
|
||||
else if(user_fmt=='mm/dd/yyyy') {
|
||||
var d = d.split('/');
|
||||
return d[2]+'-'+d[0]+'-'+d[1];
|
||||
var val = d[2]+'-'+d[0]+'-'+d[1];
|
||||
}
|
||||
else if(user_fmt=='mm-dd-yyyy') {
|
||||
var d = d.split('-');
|
||||
return d[2]+'-'+d[0]+'-'+d[1];
|
||||
var val = d[2]+'-'+d[0]+'-'+d[1];
|
||||
}
|
||||
return val + time_str;
|
||||
},
|
||||
|
||||
user_to_obj: function(d) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ wn.views.Container = Class.extend({
|
|||
change_to: function(label) {
|
||||
if(this.page && this.page.label == label) {
|
||||
// don't trigger double events
|
||||
//$(this.page).trigger('show');
|
||||
$(this.page).trigger('show');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,8 @@ wn.views.Container = Class.extend({
|
|||
// show new
|
||||
if(!this.page || this.page != page) {
|
||||
this.page = page;
|
||||
$(this.page).fadeIn();
|
||||
//$(this.page).fadeIn();
|
||||
$(this.page).toggle(true);
|
||||
}
|
||||
this.page._route = window.location.hash;
|
||||
document.title = this.page.label;
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ wn.views.GridReport = Class.extend({
|
|||
}
|
||||
input.keypress(function(e) {
|
||||
if(e.which==13) {
|
||||
me.refresh();
|
||||
me.set_route();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -213,15 +213,21 @@ wn.views.GridReport = Class.extend({
|
|||
this.waiting.toggle(false);
|
||||
if(!this.grid_wrapper)
|
||||
this.make();
|
||||
this.setup_columns();
|
||||
this.apply_link_formatters();
|
||||
this.show_zero = $('.show-zero input:checked').length;
|
||||
this.load_filter_values();
|
||||
this.setup_columns();
|
||||
this.setup_dataview_columns();
|
||||
this.apply_link_formatters();
|
||||
this.prepare_data();
|
||||
// plot might need prepared data
|
||||
this.render();
|
||||
this.render_plot();
|
||||
},
|
||||
|
||||
setup_dataview_columns: function() {
|
||||
this.dataview_columns = $.map(this.columns, function(col) {
|
||||
return !col.hidden ? col : null;
|
||||
});
|
||||
},
|
||||
make: function() {
|
||||
|
||||
// plot wrapper
|
||||
|
|
@ -255,8 +261,6 @@ wn.views.GridReport = Class.extend({
|
|||
$(this.wrapper).trigger('make');
|
||||
|
||||
},
|
||||
|
||||
|
||||
apply_filters_from_route: function() {
|
||||
var hash = window.location.hash;
|
||||
var me = this;
|
||||
|
|
@ -269,6 +273,8 @@ wn.views.GridReport = Class.extend({
|
|||
console.log("Invalid filter: " +f[0]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.init_filter_values();
|
||||
}
|
||||
},
|
||||
set_route: function() {
|
||||
|
|
@ -282,9 +288,7 @@ wn.views.GridReport = Class.extend({
|
|||
},
|
||||
render: function() {
|
||||
// new slick grid
|
||||
this.grid = new Slick.Grid("#"+this.id, this.dataView, $.map(this.columns, function(col) {
|
||||
return !col.hidden ? col : null;
|
||||
}), this.options);
|
||||
this.grid = new Slick.Grid("#"+this.id, this.dataView, this.dataview_columns, this.options);
|
||||
var me = this;
|
||||
|
||||
// bind events
|
||||
|
|
@ -305,7 +309,7 @@ wn.views.GridReport = Class.extend({
|
|||
this.dataView = new Slick.Data.DataView({ inlineFilters: true });
|
||||
this.dataView.beginUpdate();
|
||||
this.dataView.setItems(items);
|
||||
// this.dataView.setFilter(this.dataview_filter);
|
||||
if(this.dataview_filter) this.dataView.setFilter(this.dataview_filter);
|
||||
this.dataView.endUpdate();
|
||||
},
|
||||
export: function() {
|
||||
|
|
@ -339,9 +343,13 @@ wn.views.GridReport = Class.extend({
|
|||
return false;
|
||||
},
|
||||
render_plot: function() {
|
||||
if(!this.get_plot_data) return;
|
||||
var plot_data = this.get_plot_data ? this.get_plot_data() : null;
|
||||
if(!plot_data) {
|
||||
this.wrapper.find('.plot').toggle(false);
|
||||
return;
|
||||
}
|
||||
wn.require('js/lib/flot/jquery.flot.js');
|
||||
$.plot(this.wrapper.find('.plot').toggle(true), this.get_plot_data(), this.get_plot_options());
|
||||
$.plot(this.wrapper.find('.plot').toggle(true), plot_data, this.get_plot_options());
|
||||
this.setup_plot_hover();
|
||||
},
|
||||
setup_plot_hover: function() {
|
||||
|
|
@ -430,6 +438,29 @@ wn.views.GridReport = Class.extend({
|
|||
}
|
||||
return true;
|
||||
},
|
||||
apply_zero_filter: function(val, item, opts, me) {
|
||||
// show only non-zero values
|
||||
if(!me.show_zero) {
|
||||
for(var i=0, j=me.columns.length; i<j; i++) {
|
||||
var col = me.columns[i];
|
||||
if(col.formatter==me.currency_formatter) {
|
||||
if(flt(item[col.field]) > 0.001 || flt(item[col.field]) < -0.001) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
show_zero_check: function() {
|
||||
var me = this;
|
||||
this.wrapper.bind('make', function() {
|
||||
me.wrapper.find('.show-zero').toggle(true).find('input').click(function(){
|
||||
me.refresh();
|
||||
});
|
||||
});
|
||||
},
|
||||
is_default: function(fieldname) {
|
||||
return this[fieldname]==this[fieldname + "_default"];
|
||||
},
|
||||
|
|
@ -458,7 +489,7 @@ wn.views.GridReport = Class.extend({
|
|||
},
|
||||
apply_link_formatters: function() {
|
||||
var me = this;
|
||||
$.each(this.columns, function(i, col) {
|
||||
$.each(this.dataview_columns, function(i, col) {
|
||||
if(col.link_formatter) {
|
||||
col.formatter = function(row, cell, value, columnDef, dataContext) {
|
||||
// added link and open button to links
|
||||
|
|
@ -474,7 +505,7 @@ wn.views.GridReport = Class.extend({
|
|||
}
|
||||
|
||||
// make link to add a filter
|
||||
var link_formatter = wn.cur_grid_report.columns[cell].link_formatter;
|
||||
var link_formatter = wn.cur_grid_report.dataview_columns[cell].link_formatter;
|
||||
var html = repl('<a href="#" \
|
||||
onclick="wn.cur_grid_report.filter_inputs.%(col_name)s.val(\'%(value)s\'); \
|
||||
wn.cur_grid_report.set_route(); return false;">\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue