new cms with public folder
10
.gitignore
vendored
@ -1,10 +1,14 @@
|
||||
*.pyc
|
||||
*.comp.js
|
||||
.DS_Store
|
||||
files
|
||||
patch.log
|
||||
lib
|
||||
conf.py
|
||||
version.num
|
||||
user_files
|
||||
*.sql*
|
||||
public/*.html
|
||||
!public/blank.html
|
||||
!public/unsupported.html
|
||||
public/js/lib
|
||||
public/images/lib
|
||||
public/files
|
||||
public/backups
|
||||
|
13
build.json
@ -1,19 +1,20 @@
|
||||
{
|
||||
"css/all-web.css": [
|
||||
"public/css/all-web.css": [
|
||||
"erpnext/startup/startup.css",
|
||||
"erpnext/website/css/website.css"
|
||||
],
|
||||
"css/all-app.css": [
|
||||
"public/css/all-app.css": [
|
||||
"erpnext/startup/startup.css"
|
||||
],
|
||||
"js/all-web.js": [
|
||||
"public/js/all-web.js": [
|
||||
"erpnext/startup/startup.js",
|
||||
"erpnext/website/js/topbar.js"
|
||||
"conf.js"
|
||||
],
|
||||
"js/all-app.js": [
|
||||
"public/js/all-app.js": [
|
||||
"erpnext/startup/startup.js",
|
||||
"erpnext/startup/js/modules.js",
|
||||
"erpnext/startup/js/toolbar.js",
|
||||
"erpnext/startup/js/feature_setup.js"
|
||||
"erpnext/startup/js/feature_setup.js",
|
||||
"conf.js"
|
||||
]
|
||||
}
|
@ -1 +0,0 @@
|
||||
## Deprecated
|
@ -1,83 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
try:
|
||||
|
||||
import sys, os
|
||||
|
||||
sys.path.append('../lib/py')
|
||||
sys.path.append('../erpnext')
|
||||
|
||||
def getTraceback():
|
||||
import sys, traceback, string
|
||||
type, value, tb = sys.exc_info()
|
||||
body = "Traceback (innermost last):\n"
|
||||
list = traceback.format_tb(tb, None) \
|
||||
+ traceback.format_exception_only(type, value)
|
||||
body = body + "%-20s %s" % (string.join(list[:-1], ""), list[-1])
|
||||
return body
|
||||
|
||||
import cgi
|
||||
import webnotes
|
||||
import webnotes.auth
|
||||
import webnotes.utils
|
||||
import webnotes.utils.file_manager
|
||||
import webnotes.db
|
||||
import webnotes.defs
|
||||
|
||||
sys.path.append(webnotes.defs.modules_path)
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
webnotes.form_dict = {}
|
||||
|
||||
for each in form.keys():
|
||||
webnotes.form_dict[each] = form.getvalue(each)
|
||||
|
||||
n = form.getvalue('name')
|
||||
|
||||
# authenticate
|
||||
webnotes.auth.HTTPRequest()
|
||||
|
||||
# get file
|
||||
res = webnotes.utils.file_manager.get_file(n)
|
||||
|
||||
fname = res[0]
|
||||
if hasattr(res[1], 'tostring'):
|
||||
fcontent = res[1].tostring()
|
||||
else:
|
||||
fcontent = res[1]
|
||||
|
||||
if form.getvalue('thumbnail'):
|
||||
tn = webnotes.utils.cint(form.getvalue('thumbnail'))
|
||||
try:
|
||||
from PIL import Image
|
||||
import cStringIO
|
||||
|
||||
fobj = cStringIO.StringIO(fcontent)
|
||||
image = Image.open(fobj)
|
||||
image.thumbnail((tn,tn*2), Image.ANTIALIAS)
|
||||
outfile = cStringIO.StringIO()
|
||||
|
||||
if image.mode != "RGB":
|
||||
image = image.convert("RGB")
|
||||
|
||||
image.save(outfile, 'JPEG')
|
||||
outfile.seek(0)
|
||||
fcontent = outfile.read()
|
||||
except:
|
||||
pass
|
||||
|
||||
import mimetypes
|
||||
print "Content-Type: %s" % (mimetypes.guess_type(fname)[0] or 'application/unknown')
|
||||
print "Content-Disposition: filename="+fname.replace(' ', '_')
|
||||
print "Cache-Control: max-age=3600"
|
||||
print
|
||||
print fcontent
|
||||
|
||||
except Exception, e:
|
||||
print "Content-Type: text/html"
|
||||
try:
|
||||
out = {'message':'', 'exc':getTraceback().replace('\n','<br>')}
|
||||
except:
|
||||
out = {'exc': e}
|
||||
print
|
||||
print str(out)
|
@ -13,6 +13,7 @@ erpnext.set_about = function() {
|
||||
|
||||
wn.modules_path = 'erpnext';
|
||||
|
||||
// add toolbar icon
|
||||
$(document).bind('toolbar_setup', function() {
|
||||
$('.brand').html((wn.boot.website_settings.brand_html || 'erpnext') +
|
||||
' <i class="icon-home icon-white navbar-icon-home" ></i>')
|
@ -21,7 +21,6 @@
|
||||
// see ledger
|
||||
|
||||
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||
wn.require('lib/js/wn/ui/tree.js');
|
||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
||||
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
|
||||
wrapper.appframe.add_button('Refresh', function() {
|
||||
@ -340,7 +339,7 @@ pscript.make_ac_tree = function() {
|
||||
var imgsrc=null;
|
||||
var has_children = true;
|
||||
if(cl[i].group_or_ledger=='Ledger') {
|
||||
var imgsrc = 'lib/images/icons/page.png';
|
||||
var imgsrc = 'images/lib/icons/page.png';
|
||||
has_children = false;
|
||||
}
|
||||
var t = tree.addNode(n, cl[i].account_name, imgsrc,tree.std_onclick, has_children ? tree.std_onexp : null);
|
||||
@ -353,7 +352,7 @@ pscript.make_ac_tree = function() {
|
||||
var imgsrc=null;
|
||||
var has_children = true;
|
||||
if(cl[i].group_or_ledger=='Ledger') {
|
||||
var imgsrc = 'lib/images/icons/page.png';
|
||||
var imgsrc = 'images/lib/icons/page.png';
|
||||
has_children = false;
|
||||
}
|
||||
var t = tree.addNode(n, cl[i].cost_center_name, imgsrc,tree.std_onclick, has_children ? tree.std_onexp : null);
|
||||
@ -470,7 +469,7 @@ pscript.make_group_area = function(type) {
|
||||
|
||||
// refresh
|
||||
ref_btn = $a(pscript.group_area, 'div', '', {fontSize: '14px',marginBottom: '8px', marginTop: '24px', fontWeight: 'bold'});
|
||||
ref_btn.innerHTML = '<img src="lib/images/icons/page_refresh.gif" style="margin-right: 8px"><span class="link_type">Refresh Tree</span>';
|
||||
ref_btn.innerHTML = '<img src="images/lib/icons/page_refresh.gif" style="margin-right: 8px"><span class="link_type">Refresh Tree</span>';
|
||||
ref_btn.onclick= function() {
|
||||
pscript.cur_node.clear_child_nodes();
|
||||
pscript.cur_node.expand();
|
||||
@ -528,7 +527,7 @@ pscript.make_ledger_area = function() {
|
||||
|
||||
//General ledger report link
|
||||
pscript.gl_rep = $a(pscript.ledger_area, 'div','', {fontSize: '14px',marginBottom: '8px', fontWeight: 'bold'});
|
||||
pscript.gl_rep.innerHTML = '<img src="lib/images/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
|
||||
pscript.gl_rep.innerHTML = '<img src="images/lib/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
|
||||
pscript.gl_rep.onclick = function(){ pscript.make_report('gl'); }
|
||||
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ cur_frm.cscript.make_contact = function() {
|
||||
|
||||
// make purchase order list
|
||||
cur_frm.cscript.make_po_list = function(parent, doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','25%','20%','25%','25%'];
|
||||
lst.colnames = ['Sr.','Id','Status','PO Date','Grand Total'];
|
||||
@ -122,7 +122,7 @@ cur_frm.cscript.make_po_list = function(parent, doc){
|
||||
|
||||
// make purchase receipt list
|
||||
cur_frm.cscript.make_pr_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','20%','15%','20%'];
|
||||
lst.colnames = ['Sr.','Id','Status','Receipt Date','% Billed','Grand Total'];
|
||||
@ -137,7 +137,7 @@ cur_frm.cscript.make_pr_list = function(parent,doc){
|
||||
|
||||
// make purchase invoice list
|
||||
cur_frm.cscript.make_pi_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','20%','15%','20%'];
|
||||
lst.colnames = ['Sr.','Id','Posting Date','Credit To','Bill Date','Grand Total'];
|
||||
|
@ -17,11 +17,11 @@
|
||||
pscript.onload_dashboard = function() {
|
||||
// load jqplot
|
||||
wn.require('lib/css/lib/jqplot.css');
|
||||
wn.require('lib/js/lib/jqplot/jquery.jqplot.min.js');
|
||||
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.barRenderer.js');
|
||||
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
|
||||
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasTextRenderer.min.js');
|
||||
wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.categoryAxisRenderer.min.js');
|
||||
wn.require('js/lib/jqplot/jquery.jqplot.min.js');
|
||||
wn.require('js/lib/jqplot/jqplot-plugins/jqplot.barRenderer.js');
|
||||
wn.require('js/lib/jqplot/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
|
||||
wn.require('js/lib/jqplot/jqplot-plugins/jqplot.canvasTextRenderer.min.js');
|
||||
wn.require('js/lib/jqplot/jqplot-plugins/jqplot.categoryAxisRenderer.min.js');
|
||||
|
||||
|
||||
pscript.dashboard_settings = {
|
||||
|
@ -154,7 +154,7 @@ cur_frm.fields_dict['lead_name'].get_query = function(doc,dt,dn){
|
||||
// make quotation list
|
||||
// --------------------
|
||||
cur_frm.cscript.make_qtn_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
|
||||
@ -172,7 +172,7 @@ cur_frm.cscript.make_qtn_list = function(parent,doc){
|
||||
// make so list
|
||||
// -------------
|
||||
cur_frm.cscript.make_so_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','30%','25%'];
|
||||
@ -190,7 +190,7 @@ cur_frm.cscript.make_so_list = function(parent,doc){
|
||||
// make dn list
|
||||
// -------------
|
||||
cur_frm.cscript.make_dn_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
|
||||
@ -208,7 +208,7 @@ cur_frm.cscript.make_dn_list = function(parent,doc){
|
||||
// make si list
|
||||
// -------------
|
||||
cur_frm.cscript.make_si_list = function(parent,doc){
|
||||
wn.require('lib/js/legacy/widgets/listing.js');
|
||||
wn.require('js/listing.js');
|
||||
|
||||
var lst = new Listing();
|
||||
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
|
||||
|
@ -15,7 +15,6 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pscript['onload_Sales Browser'] = function(wrapper){
|
||||
wn.require('lib/js/wn/ui/tree.js');
|
||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
||||
wrapper.appframe.add_button('Refresh', function() {
|
||||
wrapper.make_tree();
|
||||
@ -128,437 +127,4 @@ erpnext.SalesChart = Class.extend({
|
||||
selected_node: function() {
|
||||
return this.tree.$w.find('.tree-link.selected');
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
pscript['onshow_Sales Browser'] = function(){
|
||||
wn.require('lib/js/legacy/widgets/tree.js');
|
||||
|
||||
var route = decodeURIComponent(location.hash);
|
||||
if(route.indexOf('/')!=-1) {
|
||||
var chart_type = route.split('/')[1];
|
||||
new SalesBrowser().set_val(chart_type)
|
||||
return;
|
||||
}
|
||||
|
||||
var parent = $i('tr_body');
|
||||
parent.innerHTML = 'Please select your chart: '
|
||||
var sel = $a(parent,'select');
|
||||
add_sel_options(sel, ['Territory', 'Customer Group', 'Item Group', 'Sales Person'], 'Territory');
|
||||
var btn = $btn(parent, 'Go', function() { new SalesBrowser().set_val(sel_val(sel)) }, {marginTop:'8px'});
|
||||
}
|
||||
|
||||
//================================= SalesBrowser Class ======================================
|
||||
SalesBrowser = function(){
|
||||
|
||||
this.make_body = function(){
|
||||
|
||||
$i('tr_header').innerHTML = '';
|
||||
$i('tr_body').innerHTML = '';
|
||||
//make header
|
||||
var desc = this.sel;
|
||||
var me = this;
|
||||
var h = new PageHeader($i('tr_header'),desc);
|
||||
h.add_button('New '+this.sel, function() { me.set_dialog(1); }, 0, 'ui-icon-plus', 1);
|
||||
h.add_button('Refresh', function() { me.refresh_tree(); }, 0, 'ui-icon-refresh');
|
||||
|
||||
var div_body = $a($i('tr_body'),'div');
|
||||
var tr_main_grid = make_table(div_body,1,2,'100%',['60%','40%'],{width: "100%", tableLayout: "fixed", borderCollapse: "collapse", border:"0px", padding:"4px 4px 4px 4px"});
|
||||
|
||||
$y($td(tr_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px", width: "60%"});
|
||||
this.tree_area = $a($td(tr_main_grid,0,0),'div','',{minHeight:'400px'});
|
||||
|
||||
$y($td(tr_main_grid,0,1),{border: "1px solid #DDD"});
|
||||
this.detail_area = $a($td(tr_main_grid,0,1),'div');
|
||||
|
||||
this.make_tree_body(this.tree_area);
|
||||
this.refresh_tree();
|
||||
}
|
||||
|
||||
this.set_val = function(b){
|
||||
var me = this;
|
||||
me.sel = b;
|
||||
me.make_body();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
SalesBrowser.prototype.make_tree_body = function(parent){
|
||||
|
||||
//this.tab2 =make_table(this.wrapper,1,2,'100%',['60%','40%']);
|
||||
this.make_tree();
|
||||
this.make_rgt_sect();
|
||||
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
SalesBrowser.prototype.make_rgt_sect=function(){
|
||||
//var d = $a($td(this.tab2,0,1),'div','',{border:'1px solid #000'});
|
||||
|
||||
this.rgt_tab =make_table(this.detail_area,4,1,'','',{padding:"4px",spacing:"4px"});
|
||||
this.dtl = $a($td(this.rgt_tab,0,0),'div');
|
||||
this.btn = $a($td(this.rgt_tab,1,0),'div','span');
|
||||
this.help = $a($td(this.rgt_tab,2,0),'div');
|
||||
this.help.innerHTML = "Note: Explore and click on the tree node to see details."
|
||||
|
||||
this.set_btn();
|
||||
}
|
||||
//=================================================================================================================================
|
||||
SalesBrowser.prototype.set_btn = function(){
|
||||
var me = this;
|
||||
this.edit_btn = $btn(this.btn,'Edit',function(){ me.set_dialog(2); });
|
||||
|
||||
this.trash_btn = $btn(this.btn,'Trash',null);
|
||||
this.trash_btn.onclick = function(){
|
||||
var check = confirm("Are you sure you want to trash "+me.cur_node.rec.name+" node?");
|
||||
|
||||
if(check){
|
||||
var arg = [me.cur_node.rec.name, me.sel];
|
||||
$c_obj('Sales Browser Control','trash_record',arg.join(','),function(r,rt){ me.refresh_tree();});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================
|
||||
SalesBrowser.prototype.set_dialog = function(f){
|
||||
|
||||
|
||||
if(this.sel == 'Territory')
|
||||
new MakeDialog('Territory','territory',f,this); //Territory Dialog
|
||||
if(this.sel == 'Customer Group')
|
||||
new MakeDialog('Customer Group','customer_group',f,this); //Customer Group Dialog
|
||||
if(this.sel == 'Item Group')
|
||||
new MakeDialog('Item Group','item_group',f,this); //Item Group Dialog
|
||||
if(this.sel == 'Sales Person')
|
||||
new MakeDialog('Sales Person','sales_person',f,this);//Sales Person Dialog
|
||||
|
||||
}
|
||||
//=====================================================Make Tree============================================================================
|
||||
SalesBrowser.prototype.make_tree = function() {
|
||||
var me = this;
|
||||
|
||||
this.tree = new Tree(this.tree_area, '100%');
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------
|
||||
// on click
|
||||
this.tree.std_onclick = function(node) {
|
||||
|
||||
me.cur_node = node;
|
||||
if(node.rec.name =='All Customer Groups' || node.rec.name =='All Sales Persons' || node.rec.name =='All Item Groups' || node.rec.name =='All Territories'){
|
||||
//$di(me.add_btn);
|
||||
|
||||
$dh(me.edit_btn);
|
||||
$dh(me.trash_btn);
|
||||
}
|
||||
else{
|
||||
//$di(me.add_btn);
|
||||
//if(node.has_children == false)
|
||||
//$dh(me.add_btn);
|
||||
|
||||
$di(me.edit_btn);
|
||||
$di(me.trash_btn);
|
||||
|
||||
}
|
||||
me.make_details();
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------------------
|
||||
// on expand
|
||||
this.tree.std_onexp = function(node) {
|
||||
|
||||
if(node.expanded_once)return;
|
||||
$di(node.loading_div);
|
||||
|
||||
var callback = function(r,rt) {
|
||||
|
||||
$dh(node.loading_div);
|
||||
var n = me.tree.allnodes[r.message.parent];
|
||||
var cl = r.message.cl;
|
||||
|
||||
for(var i=0;i<cl.length;i++) {
|
||||
var imgsrc=null;
|
||||
var has_children = true;
|
||||
|
||||
if(cl[i].is_group=='No') {
|
||||
var imgsrc = 'lib/images/icons/page.png';
|
||||
has_children = false;
|
||||
}
|
||||
var t = me.tree.addNode(n, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
|
||||
t.rec = cl[i];
|
||||
t.parent_account = r.message.parent;
|
||||
t.has_children = has_children;
|
||||
}
|
||||
|
||||
}
|
||||
var arg = [node.rec.name, me.sel];
|
||||
$c_obj('Sales Browser Control','get_record_list',arg.join(','),callback);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
SalesBrowser.prototype.make_details = function(){
|
||||
var me = this;
|
||||
var callback = function(r,rt){
|
||||
|
||||
me.dtl.innerHTML = "";
|
||||
//me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse'})
|
||||
|
||||
var h = $a(me.dtl,'h3','',{padding:'4px', margin:'0px',backgroundColor:'#EEEEEE',borderBottom:'1px solid #AAAAAA'});
|
||||
$(h).html(r.message.name);
|
||||
|
||||
var d = $a(me.dtl,'div');
|
||||
me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse',padding:'4px'})
|
||||
$td(me.dtl_tab,0,0).innerHTML="Parent";
|
||||
if(r.message.parent != '')
|
||||
$td(me.dtl_tab,0,1).innerHTML=": "+r.message.parent;
|
||||
else
|
||||
$td(me.dtl_tab,0,1).innerHTML=": ----";
|
||||
$td(me.dtl_tab,1,0).innerHTML="Has Child Node";
|
||||
$td(me.dtl_tab,1,1).innerHTML=": "+r.message.is_group;
|
||||
|
||||
|
||||
me.open_doc = $a(me.dtl,'div','link_type',{paddingTop:'14px'});
|
||||
me.open_doc.innerHTML = "Click here to open "+r.message.name;
|
||||
|
||||
me.open_doc.onclick = function(){
|
||||
loaddoc(me.sel,r.message.name );
|
||||
}
|
||||
}
|
||||
|
||||
var arg = [this.cur_node.rec.name, this.sel];
|
||||
|
||||
$c_obj('Sales Browser Control','get_record',arg.join(','),callback);
|
||||
|
||||
}
|
||||
//=================================================================================================================================
|
||||
SalesBrowser.prototype.refresh_tree=function(){
|
||||
|
||||
this.tree_area.innerHTML = '';
|
||||
this.dtl.innerHTML = '';
|
||||
this.first_level_node(); //set root
|
||||
//hide add, edit, trash buttons
|
||||
//$dh(this.add_btn);
|
||||
$dh(this.edit_btn);
|
||||
$dh(this.trash_btn);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=============================== make first level node ================================================
|
||||
SalesBrowser.prototype.first_level_node = function(){
|
||||
|
||||
var me = this;
|
||||
var callback = function(r,rt) {
|
||||
|
||||
var cl = r.message.cl;
|
||||
|
||||
for(var i=0;i<cl.length;i++) {
|
||||
var imgsrc=null;
|
||||
var has_children = true;
|
||||
|
||||
if(cl[i].is_group=='No') {
|
||||
var imgsrc = 'lib/images/icons/page.png';
|
||||
has_children = false;
|
||||
}
|
||||
me.tree_area.innerHTML = '';
|
||||
if(me.tree) {
|
||||
|
||||
me.tree.innerHTML = '';
|
||||
me.tree.body.innerHTML = '';
|
||||
|
||||
me.make_tree();
|
||||
}
|
||||
|
||||
var t = me.tree.addNode(null, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
|
||||
t.rec ={};
|
||||
t.rec.name = cl[i].name;
|
||||
t.has_children = has_children;
|
||||
}
|
||||
}
|
||||
|
||||
$c_obj('Sales Browser Control','get_fl_node',this.sel,callback);
|
||||
|
||||
}
|
||||
|
||||
//========================================= Dialog Section ===================================================================
|
||||
//--------------------------------------------------------------------------------------------------------------------------------
|
||||
//========================================================================
|
||||
MakeDialog=function(label,field_name,n,cls_obj){
|
||||
|
||||
var new_head = 'Create A New '+label;
|
||||
|
||||
this.label = label;
|
||||
|
||||
this.lbl_rec = label+' Name';
|
||||
this.field_name = field_name;
|
||||
this.n = n;
|
||||
this.cls_obj=cls_obj;
|
||||
//-----------------------------------------------
|
||||
|
||||
this.main_dialog = new Dialog(400,300,new_head);
|
||||
this.set_dg_fields();
|
||||
this.set_dg_values();
|
||||
//-----------------------------------------------
|
||||
this.new_main_dialog = this.main_dialog;
|
||||
|
||||
this.new_main_dialog.show();
|
||||
|
||||
}
|
||||
//=================================================================================================================================
|
||||
MakeDialog.prototype.set_dg_fields = function(){
|
||||
|
||||
var bd_lst = [];
|
||||
bd_lst.push(['HTML','Heading'],['Data',this.lbl_rec],['Select','Parent'],['Select','Has Child Node']);
|
||||
if(this.cls_obj.sel == 'Sales Person')
|
||||
bd_lst.push(['HTML','','All nodes are allowed in transaction.']);
|
||||
else
|
||||
bd_lst.push(['HTML','','Only leaf nodes are allowed in transaction.']);
|
||||
if(this.n==1)
|
||||
bd_lst.push(['Button','Create']);
|
||||
|
||||
if(this.n==2){
|
||||
bd_lst.push(['Button','Update']);
|
||||
this.set_edit_fields();
|
||||
}
|
||||
|
||||
this.main_dialog.make_body(bd_lst);
|
||||
|
||||
//-----------------------------------------------
|
||||
}
|
||||
|
||||
|
||||
//====================================================================================================================================
|
||||
MakeDialog.prototype.set_edit_fields=function(){
|
||||
var me = this;
|
||||
var callback = function(r,rt){
|
||||
|
||||
me.main_dialog.widgets[me.lbl_rec].value = r.message.name;
|
||||
|
||||
add_sel_options(me.main_dialog.widgets['Parent'], r.message.parent_lst,r.message.parent);
|
||||
me.main_dialog.widgets['Has Child Node'].value = r.message.is_group;
|
||||
}
|
||||
|
||||
var arg = [this.cls_obj.cur_node.rec.name, this.cls_obj.sel];
|
||||
|
||||
$c_obj('Sales Browser Control','get_record',arg.join(','),callback);
|
||||
}
|
||||
//======================================= Validation - fields entered or not =================================================
|
||||
MakeDialog.prototype.validate = function(){
|
||||
|
||||
if(!this.main_dialog.widgets[this.lbl_rec].value) {
|
||||
err_msg1 ='Please enter '+this.label +' Name'
|
||||
alert(err_msg1);
|
||||
return 1;
|
||||
}
|
||||
if(!this.main_dialog.widgets['Parent'].value){
|
||||
alert('Please enter Parent Name' );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//====================================================================================================================================
|
||||
MakeDialog.prototype.set_dg_values = function(){
|
||||
if(this.n==1){
|
||||
var me = this;
|
||||
var callback = function(r,rt){
|
||||
me.main_dialog.widgets[me.lbl_rec].disabled = 0;
|
||||
me.main_dialog.widgets['Parent'].disabled = 0;
|
||||
|
||||
add_sel_options(me.main_dialog.widgets['Parent'],r.message);
|
||||
//add_sel_options(this.main_dialog.widgets['Parent'], [this.cls_obj.cur_node.rec.name]);
|
||||
me.btn_onclick('Create',me.cls_obj);
|
||||
}
|
||||
|
||||
$c_obj('Sales Browser Control','get_parent_lst',this.cls_obj.sel,callback);
|
||||
|
||||
}
|
||||
if(this.n == 2){
|
||||
this.main_dialog.widgets[this.lbl_rec].disabled = 1;
|
||||
this.main_dialog.widgets['Parent'].disabled = 0;
|
||||
this.btn_onclick('Update');
|
||||
this.old_value = sel_val(this.main_dialog.widgets['Parent']);
|
||||
}
|
||||
|
||||
add_sel_options(this.main_dialog.widgets['Has Child Node'], ['Yes','No'], 'No');
|
||||
|
||||
}
|
||||
|
||||
//=================================================================================================================================
|
||||
//-----------------------------------------Dialog button onclick event----------------------------------------------
|
||||
MakeDialog.prototype.btn_onclick=function(btn_name){
|
||||
var me = this;
|
||||
this.btn_name = btn_name;
|
||||
this.main_dialog.widgets[this.btn_name].onclick = function() {
|
||||
|
||||
var callback=function(r,rt){
|
||||
if(r.message == 'true'){
|
||||
me.main_dialog.hide();
|
||||
}
|
||||
else{
|
||||
flag = me.validate();
|
||||
if(flag == 1) return;
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
var arg2 = me.make_args();
|
||||
|
||||
//create Sales Person -- server to Sales Browser Control
|
||||
if(me.btn_name == "Create")
|
||||
method_name = "add_node";
|
||||
else
|
||||
method_name = "edit_node";
|
||||
|
||||
$c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) {
|
||||
me.main_dialog.widgets[me.lbl_rec].value='';
|
||||
me.main_dialog.hide();
|
||||
//if(me.btn_name == "Create"){
|
||||
// me.cls_obj.cur_node.clear_child_nodes();
|
||||
// me.cls_obj.dtl.innerHTML = '';
|
||||
// me.cls_obj.cur_node.expand();
|
||||
//}
|
||||
//else{
|
||||
// me.cls_obj.refresh_tree();
|
||||
//}
|
||||
me.cls_obj.refresh_tree();
|
||||
});
|
||||
}
|
||||
}
|
||||
var arg1 = {'node_title':me.cls_obj.sel,'is_group':sel_val(me.main_dialog.widgets['Has Child Node']),'lft':0,'rgt':0,'nm':me.main_dialog.widgets[me.lbl_rec].value,'parent_nm':sel_val(me.main_dialog.widgets['Parent']),'action':me.btn_name};
|
||||
$c_obj('Sales Browser Control','mvalidate',docstring(arg1),callback);
|
||||
}
|
||||
}
|
||||
//=================================================================================================================================
|
||||
|
||||
MakeDialog.prototype.make_args = function(){
|
||||
var args ={}; //args making
|
||||
var nt = this.cls_obj.sel;
|
||||
var nm = this.main_dialog.widgets[this.lbl_rec].value;
|
||||
var pnm = sel_val(this.main_dialog.widgets['Parent']);
|
||||
var grp = sel_val(this.main_dialog.widgets['Has Child Node']);
|
||||
|
||||
if(this.n==1)
|
||||
var old_prt ='';
|
||||
else if(this.n==2){
|
||||
if(this.old_value == sel_val(this.main_dialog.widgets['Parent']))
|
||||
var old_prt = '';
|
||||
else
|
||||
var old_prt = this.old_value;
|
||||
}
|
||||
|
||||
if(this.cls_obj.sel == 'Territory')
|
||||
return {'node_title':nt,'territory_name':nm,'parent_territory':pnm,'is_group':grp,'old_parent':old_prt}
|
||||
|
||||
else if(this.cls_obj.sel == 'Customer Group')
|
||||
return {'node_title':nt,'customer_group_name':nm,'parent_customer_group':pnm,'is_group':grp,'old_parent':old_prt}
|
||||
|
||||
else if(this.cls_obj.sel == 'Item Group')
|
||||
return {'node_title':nt,'item_group_name':nm,'parent_item_group':pnm,'is_group':grp,'old_parent':old_prt}
|
||||
|
||||
else if(this.cls_obj.sel == 'Sales Person')
|
||||
return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt}
|
||||
|
||||
}
|
||||
*/
|
||||
});
|
@ -23,7 +23,7 @@ pscript['onload_Sales Dashboard'] = function() {
|
||||
//pscript.dx_axis = [];
|
||||
|
||||
wn.require('lib/css/lib/jqplot.css');
|
||||
wn.require('lib/js/lib/jqplot/jquery.jqplot.min.js');
|
||||
wn.require('js/lib/jqplot/jquery.jqplot.min.js');
|
||||
pscript.all_onchnge();
|
||||
}
|
||||
//=======================================================================
|
||||
|
@ -1,4 +1,4 @@
|
||||
wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');
|
||||
wn.require('js/lib/jquery/jquery.ui.sortable.js');
|
||||
|
||||
$.extend(wn.pages.modules_setup, {
|
||||
modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects',
|
||||
|
@ -89,6 +89,7 @@ def boot_session(bootinfo):
|
||||
if hasattr(conf, 'expires_on'): bootinfo['expires_on'] = conf.expires_on
|
||||
|
||||
|
||||
|
||||
def get_letter_heads():
|
||||
"""load letter heads with startup"""
|
||||
import webnotes
|
||||
@ -129,3 +130,23 @@ def check_if_expired():
|
||||
|
||||
webnotes.response['message'] = 'Account Expired'
|
||||
raise webnotes.AuthenticationError
|
||||
|
||||
#### website
|
||||
|
||||
def get_web_script():
|
||||
"""returns web startup script"""
|
||||
return webnotes.conn.get_value('Website Settings', None, 'startup_code') or ''
|
||||
|
||||
def get_web_style():
|
||||
"""returns web css"""
|
||||
return webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
|
||||
|
||||
def get_web_header():
|
||||
"""get website header"""
|
||||
from website.utils import get_header
|
||||
return get_header()
|
||||
|
||||
def get_web_footer():
|
||||
"""get website footer"""
|
||||
from website.utils import get_footer
|
||||
return get_footer()
|
||||
|
@ -53,22 +53,12 @@ erpnext.startup.start = function() {
|
||||
|
||||
|
||||
erpnext.startup.set_globals();
|
||||
|
||||
if(wn.boot.user_background) {
|
||||
erpnext.set_user_background(wn.boot.user_background);
|
||||
}
|
||||
|
||||
if(user == 'Guest'){
|
||||
if(wn.boot.custom_css) {
|
||||
set_style(wn.boot.custom_css);
|
||||
if(user != 'Guest'){
|
||||
if(wn.boot.user_background) {
|
||||
erpnext.set_user_background(wn.boot.user_background);
|
||||
}
|
||||
if(wn.boot.website_settings.title_prefix) {
|
||||
wn.title_prefix = wn.boot.website_settings.title_prefix;
|
||||
}
|
||||
if(wn.boot.startup_code) {
|
||||
eval(wn.boot.startup_code);
|
||||
}
|
||||
} else {
|
||||
|
||||
// always allow apps
|
||||
wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat(
|
||||
['To Do', 'Knowledge Base', 'Calendar', 'Activity', 'Messages'])
|
||||
@ -106,14 +96,14 @@ erpnext.startup.start = function() {
|
||||
</div>', { expiry_string: expiry_string }));
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.set_about();
|
||||
if(wn.control_panel.custom_startup_code)
|
||||
eval(wn.control_panel.custom_startup_code);
|
||||
}
|
||||
|
||||
erpnext.set_about();
|
||||
if(wn.control_panel.custom_startup_code)
|
||||
eval(wn.control_panel.custom_startup_code);
|
||||
|
||||
$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" href="http://erpnext.com" target="_blank"></a>')
|
||||
$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
|
||||
href="http://erpnext.com" target="_blank"></a>')
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ $.extend(wn.pages.users, {
|
||||
if(data.file_list) {
|
||||
data.imgsrc = 'files/' + data.file_list.split('\n')[0].split(',')[1];
|
||||
} else {
|
||||
data.imgsrc = 'lib/images/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
|
||||
data.imgsrc = 'images/lib/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
|
||||
}
|
||||
data.fullname = wn.user_info(data.name).fullname;
|
||||
data.delete_html = '';
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.require('lib/js/lib/jscolor/jscolor.js');
|
||||
wn.require('js/lib/jscolor/jscolor.js');
|
||||
|
||||
cur_frm.cscript.onload_post_render = function() {
|
||||
cur_frm.fields_dict.background_color.input.className = 'color';
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:48',
|
||||
'creation': '2012-04-02 16:02:43',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:48',
|
||||
'modified': '2012-05-07 15:21:00',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -19,7 +19,7 @@
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -43,16 +43,8 @@
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'label',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Label'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'custom_page',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Page',
|
||||
'options': u'Page'
|
||||
'label': u'Label',
|
||||
'width': u'120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -60,7 +52,17 @@
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'url',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'URL'
|
||||
'label': u'URL',
|
||||
'width': u'200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'target',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Target',
|
||||
'options': u'\ntarget = "_blank"'
|
||||
},
|
||||
|
||||
# DocField
|
||||
|
@ -27,6 +27,10 @@ class DocType:
|
||||
|
||||
def validate(self):
|
||||
"""make page for this product"""
|
||||
from jinja2 import Template
|
||||
from webnotes.utils import global_date_format
|
||||
from webnotes.model.code import get_obj
|
||||
import os
|
||||
|
||||
# we need the name for the templates
|
||||
if not self.doc.name:
|
||||
@ -36,11 +40,7 @@ class DocType:
|
||||
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
|
||||
|
||||
p = website.utils.add_page(self.doc.name)
|
||||
|
||||
from jinja2 import Template
|
||||
from webnotes.utils import global_date_format
|
||||
import os
|
||||
|
||||
|
||||
self.doc.updated = global_date_format(self.doc.modified)
|
||||
website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
|
||||
|
||||
@ -48,6 +48,7 @@ class DocType:
|
||||
p.content = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
p.title = self.doc.title
|
||||
p.web_page = 'Yes'
|
||||
|
||||
if self.doc.insert_code:
|
||||
p.script = self.doc.javascript
|
||||
@ -56,6 +57,7 @@ class DocType:
|
||||
p.style = self.doc.css
|
||||
|
||||
p.save()
|
||||
get_obj(doc=p).write_cms_page()
|
||||
|
||||
website.utils.add_guest_access_to_page(p.name)
|
||||
self.cleanup_temp()
|
||||
|
@ -38,7 +38,7 @@ erpnext.navbar.Navbar = Class.extend({
|
||||
<a class="brand">[brand]</a>\
|
||||
<ul class="nav">\
|
||||
</ul>\
|
||||
<img src="lib/images/ui/spinner.gif" id="spinner"/>\
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>\
|
||||
<ul class="nav pull-right">\
|
||||
<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>\
|
||||
</ul>\
|
||||
@ -75,7 +75,7 @@ erpnext.navbar.Navbar = Class.extend({
|
||||
.click(function() {
|
||||
return false;
|
||||
});
|
||||
$parent_li.append('<ul class="dropdown-menu"></ul>');
|
||||
$parent_li.append('');
|
||||
}
|
||||
erpnext.header_link_settings(item);
|
||||
$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
|
||||
@ -126,5 +126,5 @@ erpnext.header_link_settings = function(item) {
|
||||
|
||||
$(document).bind('startup', function() {
|
||||
erpnext.footer = new erpnext.Footer();
|
||||
erpnext.navbar.navbar = new erpnext.navbar.Navbar();
|
||||
//erpnext.navbar.navbar = new erpnext.navbar.Navbar();
|
||||
})
|
||||
|
@ -40,10 +40,8 @@ def markdown(doc, fields):
|
||||
|
||||
def page_name(title):
|
||||
"""make page name from title, and check that there is no duplicate"""
|
||||
import re
|
||||
name = title.lower()
|
||||
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
|
||||
return '-'.join(name.split()[:4])
|
||||
import webnotes.cms
|
||||
return webnotes.cms.page_name(title)
|
||||
|
||||
def add_page(title):
|
||||
"""add a custom page with title"""
|
||||
@ -59,7 +57,7 @@ def add_page(title):
|
||||
p.standard = 'No'
|
||||
|
||||
return p
|
||||
|
||||
|
||||
def add_guest_access_to_page(page):
|
||||
"""add Guest in Page Role"""
|
||||
if not webnotes.conn.sql("""select parent from `tabPage Role`
|
||||
@ -68,3 +66,81 @@ def add_guest_access_to_page(page):
|
||||
d.parent = page
|
||||
d.role = 'Guest'
|
||||
d.save()
|
||||
|
||||
def get_header():
|
||||
"""get page header"""
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from jinja2 import Template
|
||||
|
||||
def get_item(l, label):
|
||||
for i in l:
|
||||
if i['label']==label:
|
||||
return i
|
||||
|
||||
top_bar_items = webnotes.conn.sql("""select * from `tabTop Bar Item`
|
||||
where parent='Website Settings' and parentfield='top_bar_items'
|
||||
order by idx asc""", as_dict=1)
|
||||
|
||||
# build child items
|
||||
for t in top_bar_items:
|
||||
if t.get('parent_label'):
|
||||
pi = get_item(t['parent_label'])
|
||||
if not pi['child_items']:
|
||||
pi['child_items'] = []
|
||||
pi['child_items'].append(t)
|
||||
|
||||
website_settings = Document('Website Settings', 'Website Settings')
|
||||
|
||||
return Template("""<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand">{{ brand }}</a>
|
||||
<ul class="nav">
|
||||
{% for page in top_bar_items %}
|
||||
{% if not page.parent_label %}
|
||||
<li data-label="{{ page.label }}">
|
||||
<a href="{{ page.url }}" {{ page.target }}>
|
||||
{{ page.label }}
|
||||
{% if page.child_items %}
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target }}>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
||||
<ul class="nav pull-right">
|
||||
<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>""").render(top_bar_items = top_bar_items,
|
||||
brand=website_settings.brand_html or webnotes.get_default('company') or 'ERPNext')
|
||||
|
||||
def get_footer():
|
||||
"""get page footer"""
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from jinja2 import Template
|
||||
|
||||
website_settings = Document('Website Settings', 'Website Settings')
|
||||
|
||||
website_settings.footer_items = webnotes.conn.sql("""select * from `tabTop Bar Item`
|
||||
where parent='Website Settings' and parentfield='footer_items'
|
||||
order by idx asc""", as_dict=1)
|
||||
|
||||
return Template("""<div class="web-footer">
|
||||
<div class="web-footer-menu"><ul>
|
||||
{% for item in footer_items %}
|
||||
<li><a href="{{ item.url }}" {{ item.target }}
|
||||
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul></div>
|
||||
<div class="web-footer-copyright">© {{ copyright }}
|
||||
</div>""").render(website_settings.fields)
|
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 251 B |
@ -1249,7 +1249,7 @@ button.btn.small, input[type="submit"].btn.small {
|
||||
*margin-right: .3em;
|
||||
line-height: 14px;
|
||||
vertical-align: text-top;
|
||||
background-image: url("../lib/images/icons/glyphicons-halflings.png");
|
||||
background-image: url("../images/lib/icons/glyphicons-halflings.png");
|
||||
background-position: 14px 14px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
@ -1260,7 +1260,7 @@ button.btn.small, input[type="submit"].btn.small {
|
||||
}
|
||||
|
||||
.icon-white {
|
||||
background-image: url("../lib/images/icons/glyphicons-halflings-white.png");
|
||||
background-image: url("../images/lib/icons/glyphicons-halflings-white.png");
|
||||
}
|
||||
|
||||
.icon-glass {
|
@ -1206,7 +1206,7 @@ button.btn.small, input[type="submit"].btn.small {
|
||||
*margin-right: .3em;
|
||||
line-height: 14px;
|
||||
vertical-align: text-top;
|
||||
background-image: url("../lib/images/icons/glyphicons-halflings.png");
|
||||
background-image: url("../images/lib/icons/glyphicons-halflings.png");
|
||||
background-position: 14px 14px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
@ -1217,7 +1217,7 @@ button.btn.small, input[type="submit"].btn.small {
|
||||
}
|
||||
|
||||
.icon-white {
|
||||
background-image: url("../lib/images/icons/glyphicons-halflings-white.png");
|
||||
background-image: url("../images/lib/icons/glyphicons-halflings-white.png");
|
||||
}
|
||||
|
||||
.icon-glass {
|
69
public/css/fields.css
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
/*
|
||||
* lib/css/legacy/fields.css
|
||||
*/
|
||||
/* Documents */
|
||||
|
||||
.frm_field_table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.datalabelcell {
|
||||
padding: 2px 0px;
|
||||
width: 160px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.datainputcell { padding: 2px 0px; }
|
||||
|
||||
|
||||
.help ol {
|
||||
padding-left: 19px;
|
||||
}
|
||||
|
||||
.field_description_top {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.input_area input, select, textarea {
|
||||
font-size: 14px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.input_area input {
|
||||
width: 80%;
|
||||
margin: 0px;
|
||||
}
|
||||
.input_area select {
|
||||
width: 80%;
|
||||
}
|
||||
.input_area textarea {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.disp_area {
|
||||
width: 80%;
|
||||
padding: 2px 0px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.disp_area_no_val {
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.no_img {
|
||||
padding: 40px;
|
||||
width: 100px;
|
||||
height: 20px;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
border: 1px solid #AAA;
|
||||
}
|
||||
|
||||
.input-mandatory {
|
||||
font-size: 14px !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.field-to-update {
|
||||
background-color:#FEE;
|
||||
}
|
143
public/css/wn-web.css
Normal file
@ -0,0 +1,143 @@
|
||||
#body_div {
|
||||
|
||||
background: url("files/indian-textile-5.gif") repeat;
|
||||
|
||||
|
||||
font-family: 'Lato', Verdana, Sans !important;
|
||||
|
||||
|
||||
font-size: 14px !important;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.small {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: 'Lato', Arial, 'Helvetica Neue' !important;
|
||||
}
|
||||
|
||||
|
||||
/* User CSS */
|
||||
|
||||
hr {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
|
||||
.hand {
|
||||
font-family: Pacifico;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h1.top {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sub-head {
|
||||
text-align: center;
|
||||
color: #888;
|
||||
font-size: 18px;
|
||||
margin: 10px 0px;
|
||||
}
|
||||
|
||||
.layout-main, .layout-main-section {
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
.layout-main-section {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.layout-side-section {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
//font-family: Pacifico;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: #CC0000;
|
||||
padding: 25px 0px 25px 0px;
|
||||
clear: both;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.left {
|
||||
width: 375px;
|
||||
padding-right: 25px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.right {
|
||||
width: 375px;
|
||||
padding-left: 25px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.page-footer {
|
||||
clear: both;
|
||||
margin: -50px;
|
||||
margin-top: 50px;
|
||||
background-color: #DEE1D0; //#E7DFCA;
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
.page-footer input {
|
||||
width: 140px;
|
||||
font-size: 17px;
|
||||
padding: 4px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.page-footer .section-head {
|
||||
padding: 0px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.web-form input, .web-form textarea {
|
||||
width: 400px;
|
||||
font-size: 17px;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 75px;
|
||||
width: 75px;
|
||||
border-radius: 100px 100px 100px 100px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.link-big {
|
||||
font-size: 140%;
|
||||
}
|
||||
|
||||
.sticky {
|
||||
background-color: #FFFBC4;
|
||||
padding: 15px;
|
||||
margin-left: 15px;
|
||||
font-size: 12px;
|
||||
color: #444;
|
||||
width: 240px;
|
||||
min-height: 120px;
|
||||
float: right;
|
||||
box-shadow: 2px 2px 6px #973;
|
||||
}
|
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 516 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
@ -27,11 +27,11 @@ import cgi, cgitb, os, sys
|
||||
cgitb.enable()
|
||||
|
||||
# import libs
|
||||
sys.path.append('.')
|
||||
sys.path.append('..')
|
||||
|
||||
import conf
|
||||
|
||||
sys.path.append('lib/py')
|
||||
sys.path.append('../lib/py')
|
||||
sys.path.append(conf.modules_path)
|
||||
|
||||
import webnotes
|
||||
@ -72,11 +72,9 @@ def respond():
|
||||
if 'cmd' in webnotes.form_dict:
|
||||
webnotes.handler.handle()
|
||||
else:
|
||||
import webnotes.cms.index
|
||||
print "Content-Type: text/html"
|
||||
webnotes.handler.print_cookies()
|
||||
print
|
||||
print webnotes.cms.index.get()
|
||||
print "<html><head><script>window.location.href='index.html';</script></head></html>"
|
||||
|
||||
if __name__=="__main__":
|
||||
if init():
|
@ -184,7 +184,7 @@ wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px
|
||||
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i<options_list.length;i++){var v=options_list[i];value=v.value||v;label=v.label||v;$('<option>').html(label).attr('value',value).appendTo(this);}
|
||||
$(this).val(options_list[0].value||options_list[0]);}
|
||||
$.fn.set_working=function(){var ele=this.get(0);if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.disabled=1;ele.loading_img=$('<img src="lib/images/ui/button-load.gif" \
|
||||
$.fn.set_working=function(){var ele=this.get(0);if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.disabled=1;ele.loading_img=$('<img src="images/lib/ui/button-load.gif" \
|
||||
style="margin-left: 4px; margin-bottom: -2px; display: inline;" />').insertAfter(ele);}}
|
||||
$.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery);
|
||||
/*
|
||||
@ -201,18 +201,19 @@ wn.meta.docfield_list[df.parent].push(df);}});
|
||||
/*
|
||||
* lib/js/wn/misc/tools.js
|
||||
*/
|
||||
wn.markdown=function(txt){if(!wn.md2html){wn.require('lib/js/lib/showdown.js');wn.md2html=new Showdown.converter();}
|
||||
wn.markdown=function(txt){if(!wn.md2html){wn.require('js/lib/showdown.js');wn.md2html=new Showdown.converter();}
|
||||
return wn.md2html.makeHtml(txt);}
|
||||
/*
|
||||
* lib/js/wn/misc/user.js
|
||||
*/
|
||||
wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'}
|
||||
wn.user_info=function(uid){var def={'fullname':uid,'image':'images/lib/ui/no_img_m.gif'}
|
||||
if(!wn.boot.user_info)return def
|
||||
if(!wn.boot.user_info[uid])return def
|
||||
if(!wn.boot.user_info[uid].fullname)
|
||||
wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image)
|
||||
wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];}
|
||||
wn.provide('wn.user');$.extend(wn.user,{name:wn.boot.profile.name,has_role:function(rl){if(typeof rl=='string')rl=[rl];for(var i in rl){if(wn.boot.profile.roles.indexOf(rl[i])!=-1)
|
||||
wn.provide('wn.user');$.extend(wn.user,{name:(wn.boot?wn.boot.profile.name:'Guest'),has_role:function(rl){if(typeof rl=='string')
|
||||
rl=[rl];for(var i in rl){if((wn.boot?wn.boot.profile.roles:['Guest']).indexOf(rl[i])!=-1)
|
||||
return true;}},is_report_manager:function(){return wn.user.has_role(['Administrator','System Manager','Report Manager']);}})
|
||||
wn.session_alive=true;$(document).bind('mousemove',function(){wn.session_alive=true;if(wn.session_alive_timeout)
|
||||
clearTimeout(wn.session_alive_timeout);wn.session_alive_timeout=setTimeout('wn.session_alive=false;',30000);})
|
||||
@ -280,7 +281,7 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
|
||||
<div class="list-toolbar" style="display:inline-block; margin-right: 10px;">\
|
||||
</div>\
|
||||
<div style="display:inline-block; width: 24px; margin-left: 4px">\
|
||||
<img src="lib/images/ui/button-load.gif" \
|
||||
<img src="images/lib/ui/button-load.gif" \
|
||||
class="img-load"/></div>\
|
||||
</div><div style="clear:both"></div>\
|
||||
\
|
||||
@ -316,7 +317,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct
|
||||
/*
|
||||
* lib/js/wn/ui/filters.js
|
||||
*/
|
||||
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('lib/js/legacy/widgets/form/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
|
||||
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
|
||||
this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
|
||||
values.push(f.get_value());})
|
||||
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
|
||||
@ -366,88 +367,13 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('<span clas
|
||||
onclick="wn.set_route(\'List\', \'%(doctype)s\')">\
|
||||
<i class="icon-list icon-white"></i> %(doctype)s List\
|
||||
</span>',{doctype:doctype}));}
|
||||
/*
|
||||
* lib/js/wn/views/doclistview.js
|
||||
*/
|
||||
wn.provide('wn.views.doclistview');wn.provide('wn.doclistviews');wn.views.doclistview.show=function(doctype){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){wn.model.with_doctype(route[1],function(r){if(r&&r['403']){return;}
|
||||
new wn.views.DocListView(route[1]);});}}}
|
||||
wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=doctype;this.label=get_doctype_label(doctype);this.label=(this.label.toLowerCase().substr(-4)=='list')?this.label:(this.label+' List');this.make_page();this.setup();},make_page:function(){var me=this;var page_name=wn.get_route_str();var page=wn.container.add_page(page_name);wn.container.change_to(page_name);this.$page=$(page);this.$page.html(repl('<div class="layout-wrapper layout-wrapper-background">\
|
||||
<div class="appframe-area"></div>\
|
||||
<div class="layout-main-section">\
|
||||
<h1>%(label)s</h1>\
|
||||
<hr>\
|
||||
<div class="wnlist-area"><div class="help">Loading...</div></div>\
|
||||
</div>\
|
||||
<div class="layout-side-section">\
|
||||
<div class="stat-wrapper show-docstatus hide">\
|
||||
<h4>Show</h4>\
|
||||
<div><input data-docstatus="0" type="checkbox" checked="checked" /> Drafts</div>\
|
||||
<div><input data-docstatus="1" type="checkbox" checked="checked" /> Submitted</div>\
|
||||
<div><input data-docstatus="2" type="checkbox" /> Cancelled</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div style="clear: both"></div>\
|
||||
</div>',{label:this.label}));this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span>').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
|
||||
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
|
||||
this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
|
||||
%(description)s\
|
||||
<hr>\
|
||||
<p><button class="btn btn-info btn-small"\
|
||||
onclick="newdoc(\'%(doctype)s\');"\
|
||||
>Make a new %(doctype_label)s</button>\
|
||||
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
||||
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
||||
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
||||
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
|
||||
<div class="help small"><i>No records tagged.</i><br><br> \
|
||||
To add a tag, open the document and click on \
|
||||
"Add Tag" on the sidebar</div></div>');}
|
||||
return;}
|
||||
var label=wn.meta.docfield_map[this.doctype][field]?wn.meta.docfield_map[this.doctype][field].label:field;if(label=='_user_tags')label='Tags';var $w=$('<div class="stat-wrapper">\
|
||||
<h4>'+label+'</h4>\
|
||||
<div class="stat-grid">\
|
||||
</div>\
|
||||
</div>');stat=stat.sort(function(a,b){return b[1]-a[1]});var sum=0;$.each(stat,function(i,v){sum=sum+v[1];})
|
||||
$.each(stat,function(i,v){me.render_stat_item(i,v,sum,field).appendTo($w.find('.stat-grid'));});$w.appendTo(this.$page.find('.layout-side-section'));},render_stat_item:function(i,v,max,field){var me=this;var args={}
|
||||
args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$item=$(repl('<div class="stat-item">\
|
||||
<div class="stat-bar" style="width: %(width)s%"></div>\
|
||||
<div class="stat-label">\
|
||||
<a href="#" data-label="%(label)s" data-field="%(field)s">\
|
||||
%(label)s</a> \
|
||||
(%(count)s)</div>\
|
||||
</div>',args));this.setup_stat_item_click($item);return $item;},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}}
|
||||
this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});}
|
||||
if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;}
|
||||
if(typeof opts.content=='function'){opts.content(parent,data);}
|
||||
else if(opts.content=='name'){$(parent).append(repl('<a href="#!Form/%(doctype)s/%(name)s">%(name)s</a>',data));}
|
||||
else if(opts.content=='avatar'){$(parent).append(repl('<span class="avatar-small"><img src="%(avatar)s" \
|
||||
title="%(fullname)s"/></span>',data));}
|
||||
else if(opts.content=='check'){$(parent).append('<input class="list-delete" type="checkbox">');$(parent).find('input').data('name',data.name);}
|
||||
else if(opts.content=='docstatus'){$(parent).append(repl('<span class="docstatus"><i class="%(docstatus_icon)s" \
|
||||
title="%(docstatus_title)s"></i></span>',data));}
|
||||
else if(opts.content=='tags'){this.add_user_tags(parent,data);}
|
||||
else if(opts.content=='modified'){$(parent).append(data.when);}
|
||||
else if(opts.type=='bar-graph'){args={percent:data[opts.content],fully_delivered:(data[opts.content]>99?'bar-complete':''),label:opts.label}
|
||||
$(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(percent)s% %(label)s">\
|
||||
<span class="bar-inner %(fully_delivered)s" \
|
||||
style="width: %(percent)s%;"></span>\
|
||||
</span>',args));}
|
||||
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
||||
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
||||
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
||||
else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;data.when=dateutil.str_to_user(data.modified).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),data.modified.split(' ')[0]);if(diff==0){data.when='Today'}
|
||||
if(diff==1){data.when='Yesterday'}
|
||||
if(diff==2){data.when='2 days ago'}
|
||||
if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
|
||||
for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer">'
|
||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}})
|
||||
/*
|
||||
* lib/js/wn/views/pageview.js
|
||||
*/
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if(!locals.Page[name]){wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}else{callback();}},show:function(name){if(!name)name=wn.boot.home_page;wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if((locals.Page&&locals.Page[name])||name==window.home_page){callback();}else{wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}},show:function(name){if(!name)name=(wn.boot?wn.boot.home_page:'Login Page');wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
|
||||
wn.container.change_to(name);});}}
|
||||
wn.views.Page=Class.extend({init:function(name){this.name=name;var me=this;this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
|
||||
wn.views.Page=Class.extend({init:function(name,wrapper){this.name=name;var me=this;if(name==window.home_page){this.wrapper=document.getElementById('page-'+name);this.wrapper.title=document.title;this.wrapper.label=window.home_page;}else{this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');}
|
||||
this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
|
||||
wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html('<div class="layout-wrapper">\
|
||||
<h1>Not Found</h1><br>\
|
||||
<p>Sorry we were unable to find what you were looking for.</p>\
|
||||
@ -457,57 +383,13 @@ wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html(
|
||||
<p>Sorry you are not permitted to view this page.</p>\
|
||||
<p><a href="#">Go back to home</a></p>\
|
||||
</div>').toggle(false);};
|
||||
/*
|
||||
* lib/js/wn/views/formview.js
|
||||
*/
|
||||
wn.provide('wn.views.formview');wn.views.formview={show:function(dt,dn){if(wn.model.new_names[dn])
|
||||
dn=wn.model.new_names[dn];wn.model.with_doctype(dt,function(){wn.model.with_doc(dt,dn,function(dn,r){if(r&&r['403'])return;if(!(locals[dt]&&locals[dt][dn])){wn.container.change_to('404');return;}
|
||||
if(!wn.views.formview[dt]){wn.views.formview[dt]=wn.container.add_page('Form - '+dt);wn.views.formview[dt].frm=new _f.Frm(dt,wn.views.formview[dt]);}
|
||||
wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})},create:function(dt){var new_name=LocalDB.create(dt);wn.set_route('Form',dt,new_name);}}
|
||||
/*
|
||||
* lib/js/wn/views/reportview.js
|
||||
*/
|
||||
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t)){rb.dt.run();}}
|
||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||
wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportView(route[1],route[2]);}else{new wn.views.ReportHome();}}}}
|
||||
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname){var me=this;this.page_name=wn.get_route_str();this.import_slickgrid();this.doctype=doctype;this.docname=docname;this.tab_name='`tab'+doctype+'`';this.make_page();wn.model.with_doctype(doctype,function(){me.setup();if(docname){wn.model.with_doc('Report',docname,function(r){me.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.run();});}else{me.run();}});},import_slickgrid:function(){wn.require('lib/js/lib/slickgrid/slick.grid.css');wn.require('lib/js/lib/slickgrid/slick-default-theme.css');wn.require('lib/js/lib/slickgrid/jquery.event.drag.min.js');wn.require('lib/js/lib/slickgrid/slick.core.js');wn.require('lib/js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_full_column_name([this.sort_by_select.val()])
|
||||
+' '+this.sort_order_select.val()
|
||||
if(this.sort_by_next_select.val()){order_by+=', '+this.get_full_column_name([this.sort_by_next_select.val()])
|
||||
+' '+this.sort_order_next_select.val()}
|
||||
return order_by;},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){return{id:c[0],field:c[0],name:(wn.meta.docfield_map[c[1]||me.doctype][c[0]]?wn.meta.docfield_map[c[1]||me.doctype][c[0]].label:toTitle(c[0])),width:120}});},render_list:function(){var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
|
||||
<div class="sort-column"></div>\
|
||||
<div><select class="sort-order" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div>\
|
||||
<hr><p class="help">Then By (optional)</p>\
|
||||
<div class="sort-column-1"></div>\
|
||||
<div><select class="sort-order-1" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div><hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');this.sort_by_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column'),this.doctype).$select;this.sort_by_select.css('width','60%');this.sort_order_select=$(this.sort_dialog.body).find('.sort-order');this.sort_by_next_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column-1'),this.doctype,null,true).$select;this.sort_by_next_select.css('width','60%');this.sort_order_next_select=$(this.sort_dialog.body).find('.sort-order-1');this.sort_by_select.val('modified');this.sort_order_select.val('desc');this.sort_by_next_select.val('');this.sort_order_next_select.val('desc');this.page.appframe.add_button('Sort By',function(){me.sort_dialog.show();},'icon-arrow-down');$(this.sort_dialog.body).find('.btn-info').click(function(){me.sort_dialog.hide();me.run();});},make_export:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Export',function(){var args=me.get_args();args.cmd='webnotes.widgets.doclistview.export_query'
|
||||
open_url_post(wn.request.url,args);},'icon-download-alt');}},make_save:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Save',function(){if(me.docname){var name=me.docname}else{var name=prompt('Select Report Name');if(!name){return;}}
|
||||
wn.call({method:'webnotes.widgets.doclistview.save_report',args:{name:name,doctype:me.doctype,json:JSON.stringify({filters:me.filter_list.get_filters(),columns:me.columns,sort_by:me.sort_by_select.val(),sort_order:me.sort_order_select.val(),sort_by_next:me.sort_by_next_select.val(),sort_order_next:me.sort_order_next_select.val()})},callback:function(r){if(r.exc)return;if(r.message!=me.docname)
|
||||
wn.set_route('Report2',me.doctype,r.message);}});},'icon-upload');}}});wn.ui.ColumnPicker=Class.extend({init:function(list){this.list=list;this.doctype=list.doctype;this.selects={};},show:function(columns){wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');var me=this;if(!this.dialog){this.dialog=new wn.ui.Dialog({title:'Pick Columns',width:'400'});}
|
||||
$(this.dialog.body).html('<div class="help">Drag to sort columns</div>\
|
||||
<div class="column-list"></div>\
|
||||
<div><button class="btn btn-small btn-add"><i class="icon-plus"></i>\
|
||||
Add Column</button></div>\
|
||||
<hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');$.each(columns,function(i,c){me.add_column(c);});$(this.dialog.body).find('.column-list').sortable();$(this.dialog.body).find('.btn-add').click(function(){me.add_column('name');});$(this.dialog.body).find('.btn-info').click(function(){me.dialog.hide();me.list.columns=[];$(me.dialog.body).find('select').each(function(){me.list.columns.push([$(this).val(),$(this).find('option:selected').attr('table')]);})
|
||||
me.list.run();});this.dialog.show();},add_column:function(c){var w=$('<div style="padding: 5px 5px 5px 35px; background-color: #eee; width: 70%; \
|
||||
margin-bottom: 10px; border-radius: 3px; cursor: move;">\
|
||||
<a class="close" style="margin-top: 5px;">×</a>\
|
||||
</div>').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val(c);w.find('.close').click(function(){$(this).parent().remove();});}});
|
||||
/*
|
||||
* lib/js/wn/request.js
|
||||
*/
|
||||
wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
throw"Incomplete Request";}}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){msgprint('Session Expired. Logging you out');if(!wn.app.logged_out)
|
||||
wn.app.logout();return;}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
|
||||
return;}
|
||||
if(r.server_messages)msgprint(r.server_messages)
|
||||
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
||||
if(r.docs)LocalDB.sync(r.docs);}
|
||||
@ -521,7 +403,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f
|
||||
* lib/js/core.js
|
||||
*/
|
||||
if(!console){var console={log:function(txt){}}}
|
||||
wn.versions.check();$(document).bind('ready',function(){wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
|
||||
$(document).bind('ready',function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
|
||||
|
||||
/*
|
||||
* lib/js/legacy/globals.js
|
||||
@ -548,7 +430,7 @@ function is_null(v){if(v==null){return 1}else if(v==0){if((v+'').length>=1)retur
|
||||
function $s(ele,v,ftype,fopt){if(v==null)v='';if(ftype=='Text'||ftype=='Small Text'){ele.innerHTML=v?v.replace(/\n/g,'<br>'):'';}else if(ftype=='Date'){v=dateutil.str_to_user(v);if(v==null)v=''
|
||||
ele.innerHTML=v;}else if(ftype=='Link'&&fopt){ele.innerHTML='';doc_link(ele,fopt,v);}else if(ftype=='Currency'){ele.style.textAlign='right';if(is_null(v))
|
||||
ele.innerHTML='';else
|
||||
ele.innerHTML=fmt_money(v);}else if(ftype=='Int'){ele.style.textAlign='right';ele.innerHTML=v;}else if(ftype=='Check'){if(v)ele.innerHTML='<img src="lib/images/ui/tick.gif">';else ele.innerHTML='';}else{ele.innerHTML=v;}}
|
||||
ele.innerHTML=fmt_money(v);}else if(ftype=='Int'){ele.style.textAlign='right';ele.innerHTML=v;}else if(ftype=='Check'){if(v)ele.innerHTML='<img src="images/lib/ui/tick.gif">';else ele.innerHTML='';}else{ele.innerHTML=v;}}
|
||||
function clean_smart_quotes(s){if(s){s=s.replace(/\u2018/g,"'");s=s.replace(/\u2019/g,"'");s=s.replace(/\u201c/g,'"');s=s.replace(/\u201d/g,'"');s=s.replace(/\u2013/g,'-');s=s.replace(/\u2014/g,'--');}
|
||||
return s;}
|
||||
function copy_dict(d){var n={};for(var k in d)n[k]=d[k];return n;}
|
||||
@ -629,8 +511,8 @@ var time_to_ampm=wn.datetime.time_to_ampm;var time_to_hhmm=wn.datetime.time_to_h
|
||||
* lib/js/legacy/utils/dom.js
|
||||
*/
|
||||
wn.tinymce={add_simple:function(ele,height){if(ele.myid){tinyMCE.execCommand('mceAddControl',true,ele.myid);return;}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='lib/images/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='images/lib/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
span.set_working=function(){this.disabled=1;$di(this.loading_img);}
|
||||
span.done_working=function(){this.disabled=0;$dh(this.loading_img);}
|
||||
return span;}}
|
||||
@ -735,7 +617,7 @@ if(!msg_dialog){msg_dialog=new Dialog(500,200,"Message");msg_dialog.make_body([[
|
||||
msg_dialog.onhide=function(){msg_dialog.msg_area.innerHTML='';$dh(msg_dialog.msg_icon);if(msg_dialog.custom_onhide)msg_dialog.custom_onhide();}
|
||||
$y(msg_dialog.rows['Msg'],{fontSize:'14px',lineHeight:'1.5em',padding:'16px'})
|
||||
var t=make_table(msg_dialog.rows['Msg'],1,2,'100%',['20px','250px'],{padding:'2px',verticalAlign:'Top'});msg_dialog.msg_area=$td(t,0,1);msg_dialog.msg_icon=$a($td(t,0,0),'img');}
|
||||
if(!msg_dialog.display)msg_dialog.show();var has_msg=msg_dialog.msg_area.innerHTML?1:0;var m=$a(msg_dialog.msg_area,'div','');if(has_msg)$y(m,{marginTop:'4px'});$dh(msg_dialog.msg_icon);if(msg.substr(0,6).toLowerCase()=='error:'){msg_dialog.msg_icon.src='lib/images/icons/error.gif';$di(msg_dialog.msg_icon);msg=msg.substr(6);}else if(msg.substr(0,8).toLowerCase()=='message:'){msg_dialog.msg_icon.src='lib/images/icons/application.gif';$di(msg_dialog.msg_icon);msg=msg.substr(8);}else if(msg.substr(0,3).toLowerCase()=='ok:'){msg_dialog.msg_icon.src='lib/images/icons/accept.gif';$di(msg_dialog.msg_icon);msg=msg.substr(3);}
|
||||
if(!msg_dialog.display)msg_dialog.show();var has_msg=msg_dialog.msg_area.innerHTML?1:0;var m=$a(msg_dialog.msg_area,'div','');if(has_msg)$y(m,{marginTop:'4px'});$dh(msg_dialog.msg_icon);if(msg.substr(0,6).toLowerCase()=='error:'){msg_dialog.msg_icon.src='images/lib/icons/error.gif';$di(msg_dialog.msg_icon);msg=msg.substr(6);}else if(msg.substr(0,8).toLowerCase()=='message:'){msg_dialog.msg_icon.src='images/lib/icons/application.gif';$di(msg_dialog.msg_icon);msg=msg.substr(8);}else if(msg.substr(0,3).toLowerCase()=='ok:'){msg_dialog.msg_icon.src='images/lib/icons/accept.gif';$di(msg_dialog.msg_icon);msg=msg.substr(3);}
|
||||
m.innerHTML=replace_newlines(msg);if(m.offsetHeight>200){$y(m,{height:'200px',width:'400px',overflow:'auto'})}
|
||||
msg_dialog.custom_onhide=callback;}
|
||||
var growl_area;function show_alert(txt,id){if(!growl_area){if(!$('#dialog-container').length){$('<div id="dialog-container">').appendTo('body');}
|
||||
@ -767,7 +649,7 @@ Field.prototype.make_body=function(){var ischk=(this.df.fieldtype=='Check'?1:0);
|
||||
this.wrapper=$a(this.parent,(this.with_label?'div':'span'));else
|
||||
this.wrapper=document.createElement((this.with_label?'div':'span'));this.label_area=$a(this.wrapper,'div','',{margin:'0px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});}
|
||||
if(this.with_label){this.label_span=$a(this.label_area,'span','small')
|
||||
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='lib/images/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='lib/images/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
|
||||
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='images/lib/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='images/lib/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
|
||||
$dh(this.label_area);}
|
||||
if(!this.input_area){this.input_area=$a(this.wrapper,(this.with_label?'div':'span'));this.disp_area=$a(this.wrapper,(this.with_label?'div':'span'));}
|
||||
if(this.in_grid){if(this.label_area)$dh(this.label_area);}else{this.input_area.className='input_area';$y(this.wrapper,{marginBottom:'9px'});this.set_description();}
|
||||
@ -890,7 +772,7 @@ CurrencyField.prototype.validate=function(v){if(v==null||v=='')
|
||||
return 0;return flt(v,2);}
|
||||
CurrencyField.prototype.set_disp=function(val){var v=fmt_money(val);this.set_disp_html(v);}
|
||||
CurrencyField.prototype.onmake_input=function(){if(!this.input)return;this.input.onfocus=function(){if(flt(this.value)==0)this.select();}}
|
||||
function CheckField(){}CheckField.prototype=new Field();CheckField.prototype.validate=function(v){var v=parseInt(v);if(isNaN(v))return 0;return v;};CheckField.prototype.onmake=function(){this.checkimg=$a(this.disp_area,'div');var img=$a(this.checkimg,'img');img.src='lib/images/ui/tick.gif';$dh(this.checkimg);}
|
||||
function CheckField(){}CheckField.prototype=new Field();CheckField.prototype.validate=function(v){var v=parseInt(v);if(isNaN(v))return 0;return v;};CheckField.prototype.onmake=function(){this.checkimg=$a(this.disp_area,'div');var img=$a(this.checkimg,'img');img.src='images/lib/ui/tick.gif';$dh(this.checkimg);}
|
||||
CheckField.prototype.make_input=function(){var me=this;this.input=$a_input(this.input_area,'checkbox');$y(this.input,{width:"16px",border:'0px',margin:'2px'});$(this.input).click(function(){me.set(this.checked?1:0);me.run_trigger();})
|
||||
this.input.set_input=function(v){v=parseInt(v);if(isNaN(v))v=0;if(v)me.input.checked=true;else me.input.checked=false;}
|
||||
this.get_value=function(){return this.input.checked?1:0;}}
|
||||
@ -992,7 +874,7 @@ opts.parent.appframe=new wn.ui.AppFrame($(opts.parent).find('.layout-appframe'))
|
||||
/*
|
||||
* lib/js/wn/ui/dialog.js
|
||||
*/
|
||||
wn.widgets.FieldGroup=function(){this.first_button=false;this.make_fields=function(body,fl){if(!window.make_field){wn.require('lib/css/legacy/fields.css');wn.require('lib/js/legacy/widgets/form/fields.js');wn.require('lib/js/wn/ui/button.js');}
|
||||
wn.widgets.FieldGroup=function(){this.first_button=false;this.make_fields=function(body,fl){if(!window.make_field){wn.require('css/fields.css');wn.require('js/fields.js');}
|
||||
$y(this.body,{padding:'11px'});this.fields_dict={};for(var i=0;i<fl.length;i++){var df=fl[i];var div=$a(body,'div','',{margin:'6px 0px'})
|
||||
f=make_field(df,null,div,null);f.not_in_form=1;this.fields_dict[df.fieldname]=f
|
||||
f.refresh();if(df.fieldtype=='Button'&&!this.first_button){$(f.input).addClass('btn-info');this.first_button=true;}}}
|
||||
@ -1021,7 +903,7 @@ $(document).bind('keydown',function(e){if(cur_dialog&&!cur_dialog.no_cancel_flag
|
||||
/*
|
||||
* lib/js/wn/ui/button.js
|
||||
*/
|
||||
wn.ui.Button=function(args){var me=this;$.extend(this,{make:function(){me.btn=wn.dom.add(args.parent,'button','btn btn-small '+(args.css_class||''));me.btn.args=args;me.loading_img=wn.dom.add(me.btn.args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});me.loading_img.src='lib/images/ui/button-load.gif';if(args.is_ajax)wn.dom.css(me.btn,{marginRight:'24px'});me.btn.innerHTML=args.label;me.btn.user_onclick=args.onclick;$(me.btn).bind('click',function(){if(!this.disabled&&this.user_onclick)
|
||||
wn.ui.Button=function(args){var me=this;$.extend(this,{make:function(){me.btn=wn.dom.add(args.parent,'button','btn btn-small '+(args.css_class||''));me.btn.args=args;me.loading_img=wn.dom.add(me.btn.args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});me.loading_img.src='images/lib/ui/button-load.gif';if(args.is_ajax)wn.dom.css(me.btn,{marginRight:'24px'});me.btn.innerHTML=args.label;me.btn.user_onclick=args.onclick;$(me.btn).bind('click',function(){if(!this.disabled&&this.user_onclick)
|
||||
this.user_onclick(this);})
|
||||
me.btn.set_working=me.set_working;me.btn.done_working=me.done_working;if(me.btn.args.style)
|
||||
wn.dom.css(me.btn,args.style);},set_working:function(){me.btn.disabled='disabled';if(me.btn.args.is_ajax){$(me.btn).css('margin-right','0px');}
|
||||
@ -1034,6 +916,151 @@ wn.ui.Search=Class.extend({init:function(opts){$.extend(this,opts);var me=this;w
|
||||
+data.name+'</a>').appendTo(parent).click(function(){var val=$(this).attr('data-name');me.dialog.hide();if(me.callback)
|
||||
me.callback(val);else
|
||||
wn.set_route('Form',me.doctype,val);});}});this.list.filter_list.add_filter('name','like');this.list.run();}})
|
||||
/*
|
||||
* lib/js/wn/ui/tree.js
|
||||
*/
|
||||
wn.ui.Tree=Class.extend({init:function(args){$.extend(this,args);this.nodes={};this.$w=$('<div class="tree">').appendTo(this.parent);this.rootnode=new wn.ui.TreeNode({tree:this,parent:this.$w,label:this.label,expandable:true});this.set_style();},set_style:function(){wn.dom.set_style("\
|
||||
.tree li { list-style: none; }\
|
||||
.tree ul { margin-top: 2px; }\
|
||||
.tree-link { cursor: pointer; }\
|
||||
")}})
|
||||
wn.ui.TreeNode=Class.extend({init:function(args){var me=this;$.extend(this,args);this.loaded=false;this.expanded=false;this.tree.nodes[this.label]=this;this.$a=$('<a class="tree-link">').click(function(){if(me.expandable&&me.tree.method&&!me.loaded){me.load()}else{me.selectnode();}
|
||||
if(me.tree.click)me.tree.click(this);}).bind('reload',function(){me.reload();}).data('label',this.label).appendTo(this.parent);if(this.expandable){this.$a.append('<i class="icon-folder-close"></i> '+this.label);}else{this.$a.append('<i class="icon-file"></i> '+this.label);}},selectnode:function(){if(this.$ul){this.$ul.toggle();this.$a.find('i').removeClass();if(this.$ul.css('display').toLowerCase()=='block'){this.$a.find('i').addClass('icon-folder-open');}else{this.$a.find('i').addClass('icon-folder-close');}}
|
||||
this.tree.$w.find('a.selected').removeClass('selected');this.$a.toggleClass('selected');this.expanded=!this.expanded;},reload:function(){if(this.expanded){this.$a.click();}
|
||||
if(this.$ul){this.$ul.empty();}
|
||||
this.load();},addnode:function(label,expandable){if(!this.$ul){this.$ul=$('<ul>').toggle(false).appendTo(this.parent);}
|
||||
return new wn.ui.TreeNode({tree:this.tree,parent:$('<li>').appendTo(this.$ul),label:label,expandable:expandable});},load:function(){var me=this;args=$.extend(this.tree.args,{parent:this.label});$(me.$a).set_working();wn.call({method:this.tree.method,args:args,callback:function(r){$(me.$a).done_working();$.each(r.message,function(i,v){node=me.addnode(v.value||v,v.expandable);node.$a.data('node-data',v);});me.loaded=true;me.selectnode();}})}})
|
||||
/*
|
||||
* lib/js/wn/misc/about.js
|
||||
*/
|
||||
wn.provide('wn.ui.misc');wn.ui.misc.about=function(){if(!wn.ui.misc.about_dialog){var d=new wn.widgets.Dialog({title:'About wnframework'})
|
||||
$(d.body).html(repl("<div style='padding: 20px'<p><b>Application Name:</b> %(name)s</p>\
|
||||
<p><b>Version:</b> %(version)s</p>\
|
||||
<p><b>License:</b> %(license)s</p>\
|
||||
<p><b>Source Code:</b> %(source)s</p>\
|
||||
<p><b>Publisher:</b> %(publisher)s</p>\
|
||||
<p><b>Copyright:</b> %(copyright)s</p></div>",wn.app));wn.ui.misc.about_dialog=d;}
|
||||
wn.ui.misc.about_dialog.show();}
|
||||
/*
|
||||
* lib/js/wn/views/doclistview.js
|
||||
*/
|
||||
wn.provide('wn.views.doclistview');wn.provide('wn.doclistviews');wn.views.doclistview.show=function(doctype){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){wn.model.with_doctype(route[1],function(r){if(r&&r['403']){return;}
|
||||
new wn.views.DocListView(route[1]);});}}}
|
||||
wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=doctype;this.label=get_doctype_label(doctype);this.label=(this.label.toLowerCase().substr(-4)=='list')?this.label:(this.label+' List');this.make_page();this.setup();},make_page:function(){var me=this;var page_name=wn.get_route_str();var page=wn.container.add_page(page_name);wn.container.change_to(page_name);this.$page=$(page);this.$page.html(repl('<div class="layout-wrapper layout-wrapper-background">\
|
||||
<div class="appframe-area"></div>\
|
||||
<div class="layout-main-section">\
|
||||
<h1>%(label)s</h1>\
|
||||
<hr>\
|
||||
<div class="wnlist-area"><div class="help">Loading...</div></div>\
|
||||
</div>\
|
||||
<div class="layout-side-section">\
|
||||
<div class="stat-wrapper show-docstatus hide">\
|
||||
<h4>Show</h4>\
|
||||
<div><input data-docstatus="0" type="checkbox" checked="checked" /> Drafts</div>\
|
||||
<div><input data-docstatus="1" type="checkbox" checked="checked" /> Submitted</div>\
|
||||
<div><input data-docstatus="2" type="checkbox" /> Cancelled</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div style="clear: both"></div>\
|
||||
</div>',{label:this.label}));this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span>').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
|
||||
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
|
||||
this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
|
||||
%(description)s\
|
||||
<hr>\
|
||||
<p><button class="btn btn-info btn-small"\
|
||||
onclick="newdoc(\'%(doctype)s\');"\
|
||||
>Make a new %(doctype_label)s</button>\
|
||||
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
||||
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
||||
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
||||
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
|
||||
<div class="help small"><i>No records tagged.</i><br><br> \
|
||||
To add a tag, open the document and click on \
|
||||
"Add Tag" on the sidebar</div></div>');}
|
||||
return;}
|
||||
var label=wn.meta.docfield_map[this.doctype][field]?wn.meta.docfield_map[this.doctype][field].label:field;if(label=='_user_tags')label='Tags';var $w=$('<div class="stat-wrapper">\
|
||||
<h4>'+label+'</h4>\
|
||||
<div class="stat-grid">\
|
||||
</div>\
|
||||
</div>');stat=stat.sort(function(a,b){return b[1]-a[1]});var sum=0;$.each(stat,function(i,v){sum=sum+v[1];})
|
||||
$.each(stat,function(i,v){me.render_stat_item(i,v,sum,field).appendTo($w.find('.stat-grid'));});$w.appendTo(this.$page.find('.layout-side-section'));},render_stat_item:function(i,v,max,field){var me=this;var args={}
|
||||
args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$item=$(repl('<div class="stat-item">\
|
||||
<div class="stat-bar" style="width: %(width)s%"></div>\
|
||||
<div class="stat-label">\
|
||||
<a href="#" data-label="%(label)s" data-field="%(field)s">\
|
||||
%(label)s</a> \
|
||||
(%(count)s)</div>\
|
||||
</div>',args));this.setup_stat_item_click($item);return $item;},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}}
|
||||
this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});}
|
||||
if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;}
|
||||
if(typeof opts.content=='function'){opts.content(parent,data);}
|
||||
else if(opts.content=='name'){$(parent).append(repl('<a href="#!Form/%(doctype)s/%(name)s">%(name)s</a>',data));}
|
||||
else if(opts.content=='avatar'){$(parent).append(repl('<span class="avatar-small"><img src="%(avatar)s" \
|
||||
title="%(fullname)s"/></span>',data));}
|
||||
else if(opts.content=='check'){$(parent).append('<input class="list-delete" type="checkbox">');$(parent).find('input').data('name',data.name);}
|
||||
else if(opts.content=='docstatus'){$(parent).append(repl('<span class="docstatus"><i class="%(docstatus_icon)s" \
|
||||
title="%(docstatus_title)s"></i></span>',data));}
|
||||
else if(opts.content=='tags'){this.add_user_tags(parent,data);}
|
||||
else if(opts.content=='modified'){$(parent).append(data.when);}
|
||||
else if(opts.type=='bar-graph'){args={percent:data[opts.content],fully_delivered:(data[opts.content]>99?'bar-complete':''),label:opts.label}
|
||||
$(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(percent)s% %(label)s">\
|
||||
<span class="bar-inner %(fully_delivered)s" \
|
||||
style="width: %(percent)s%;"></span>\
|
||||
</span>',args));}
|
||||
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
||||
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
||||
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
||||
else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;data.when=dateutil.str_to_user(data.modified).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),data.modified.split(' ')[0]);if(diff==0){data.when='Today'}
|
||||
if(diff==1){data.when='Yesterday'}
|
||||
if(diff==2){data.when='2 days ago'}
|
||||
if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
|
||||
for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer">'
|
||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}})
|
||||
/*
|
||||
* lib/js/wn/views/formview.js
|
||||
*/
|
||||
wn.provide('wn.views.formview');wn.views.formview={show:function(dt,dn){if(wn.model.new_names[dn])
|
||||
dn=wn.model.new_names[dn];wn.model.with_doctype(dt,function(){wn.model.with_doc(dt,dn,function(dn,r){if(r&&r['403'])return;if(!(locals[dt]&&locals[dt][dn])){wn.container.change_to('404');return;}
|
||||
if(!wn.views.formview[dt]){wn.views.formview[dt]=wn.container.add_page('Form - '+dt);wn.views.formview[dt].frm=new _f.Frm(dt,wn.views.formview[dt]);}
|
||||
wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})},create:function(dt){var new_name=LocalDB.create(dt);wn.set_route('Form',dt,new_name);}}
|
||||
/*
|
||||
* lib/js/wn/views/reportview.js
|
||||
*/
|
||||
wn.views.reportview={show:function(dt,rep_name){wn.require('js/report-legacy.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t)){rb.dt.run();}}
|
||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||
wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportView(route[1],route[2]);}else{new wn.views.ReportHome();}}}}
|
||||
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname){var me=this;this.page_name=wn.get_route_str();this.import_slickgrid();this.doctype=doctype;this.docname=docname;this.tab_name='`tab'+doctype+'`';this.make_page();wn.model.with_doctype(doctype,function(){me.setup();if(docname){wn.model.with_doc('Report',docname,function(r){me.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.run();});}else{me.run();}});},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_full_column_name([this.sort_by_select.val()])
|
||||
+' '+this.sort_order_select.val()
|
||||
if(this.sort_by_next_select.val()){order_by+=', '+this.get_full_column_name([this.sort_by_next_select.val()])
|
||||
+' '+this.sort_order_next_select.val()}
|
||||
return order_by;},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){return{id:c[0],field:c[0],name:(wn.meta.docfield_map[c[1]||me.doctype][c[0]]?wn.meta.docfield_map[c[1]||me.doctype][c[0]].label:toTitle(c[0])),width:120}});},render_list:function(){var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
|
||||
<div class="sort-column"></div>\
|
||||
<div><select class="sort-order" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div>\
|
||||
<hr><p class="help">Then By (optional)</p>\
|
||||
<div class="sort-column-1"></div>\
|
||||
<div><select class="sort-order-1" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div><hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');this.sort_by_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column'),this.doctype).$select;this.sort_by_select.css('width','60%');this.sort_order_select=$(this.sort_dialog.body).find('.sort-order');this.sort_by_next_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column-1'),this.doctype,null,true).$select;this.sort_by_next_select.css('width','60%');this.sort_order_next_select=$(this.sort_dialog.body).find('.sort-order-1');this.sort_by_select.val('modified');this.sort_order_select.val('desc');this.sort_by_next_select.val('');this.sort_order_next_select.val('desc');this.page.appframe.add_button('Sort By',function(){me.sort_dialog.show();},'icon-arrow-down');$(this.sort_dialog.body).find('.btn-info').click(function(){me.sort_dialog.hide();me.run();});},make_export:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Export',function(){var args=me.get_args();args.cmd='webnotes.widgets.doclistview.export_query'
|
||||
open_url_post(wn.request.url,args);},'icon-download-alt');}},make_save:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Save',function(){if(me.docname){var name=me.docname}else{var name=prompt('Select Report Name');if(!name){return;}}
|
||||
wn.call({method:'webnotes.widgets.doclistview.save_report',args:{name:name,doctype:me.doctype,json:JSON.stringify({filters:me.filter_list.get_filters(),columns:me.columns,sort_by:me.sort_by_select.val(),sort_order:me.sort_order_select.val(),sort_by_next:me.sort_by_next_select.val(),sort_order_next:me.sort_order_next_select.val()})},callback:function(r){if(r.exc)return;if(r.message!=me.docname)
|
||||
wn.set_route('Report2',me.doctype,r.message);}});},'icon-upload');}}});wn.ui.ColumnPicker=Class.extend({init:function(list){this.list=list;this.doctype=list.doctype;this.selects={};},show:function(columns){wn.require('js/lib/jquery/jquery.ui.sortable.js');var me=this;if(!this.dialog){this.dialog=new wn.ui.Dialog({title:'Pick Columns',width:'400'});}
|
||||
$(this.dialog.body).html('<div class="help">Drag to sort columns</div>\
|
||||
<div class="column-list"></div>\
|
||||
<div><button class="btn btn-small btn-add"><i class="icon-plus"></i>\
|
||||
Add Column</button></div>\
|
||||
<hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');$.each(columns,function(i,c){me.add_column(c);});$(this.dialog.body).find('.column-list').sortable();$(this.dialog.body).find('.btn-add').click(function(){me.add_column('name');});$(this.dialog.body).find('.btn-info').click(function(){me.dialog.hide();me.list.columns=[];$(me.dialog.body).find('select').each(function(){me.list.columns.push([$(this).val(),$(this).find('option:selected').attr('table')]);})
|
||||
me.list.run();});this.dialog.show();},add_column:function(c){var w=$('<div style="padding: 5px 5px 5px 35px; background-color: #eee; width: 70%; \
|
||||
margin-bottom: 10px; border-radius: 3px; cursor: move;">\
|
||||
<a class="close" style="margin-top: 5px;">×</a>\
|
||||
</div>').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val(c);w.find('.close').click(function(){$(this).parent().remove();});}});
|
||||
/*
|
||||
* lib/js/legacy/widgets/dialog.js
|
||||
*/
|
||||
@ -1405,7 +1432,7 @@ wn.ui.toolbar.Toolbar=Class.extend({init:function(){this.make();this.make_home()
|
||||
<a class="brand"></a>\
|
||||
<ul class="nav">\
|
||||
</ul>\
|
||||
<img src="lib/images/ui/spinner.gif" id="spinner"/>\
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>\
|
||||
<ul class="nav pull-right">\
|
||||
<li class="dropdown">\
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#" \
|
||||
@ -1439,7 +1466,7 @@ wn.ui.toolbar.Toolbar=Class.extend({init:function(){this.make();this.make_home()
|
||||
onclick="return wn.ui.toolbar.download_backup();">\
|
||||
Download Backup</a></li>');}},set_user_name:function(){var fn=user_fullname;if(fn.length>15)fn=fn.substr(0,12)+'...';$('#toolbar-user-link').html(fn+'<b class="caret"></b>');},make_logout:function(){$('#toolbar-user').append('<li><a href="#" onclick="return wn.app.logout();">Logout</a></li>');}});wn.ui.toolbar.clear_cache=function(){localStorage&&localStorage.clear();$c('webnotes.session_cache.clear',{},function(r,rt){if(!r.exc){show_alert(r.message);location.reload();}});return false;}
|
||||
wn.ui.toolbar.download_backup=function(){$c('webnotes.utils.backups.get_backup',{},function(r,rt){});return false;}
|
||||
wn.ui.toolbar.show_about=function(){try{wn.require('lib/js/wn/misc/about.js');wn.ui.misc.about();}catch(e){console.log(e);}
|
||||
wn.ui.toolbar.show_about=function(){try{wn.ui.misc.about();}catch(e){console.log(e);}
|
||||
return false;}
|
||||
|
||||
/*
|
||||
@ -1458,7 +1485,7 @@ Field.prototype.make_body=function(){var ischk=(this.df.fieldtype=='Check'?1:0);
|
||||
this.wrapper=$a(this.parent,(this.with_label?'div':'span'));else
|
||||
this.wrapper=document.createElement((this.with_label?'div':'span'));this.label_area=$a(this.wrapper,'div','',{margin:'0px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});}
|
||||
if(this.with_label){this.label_span=$a(this.label_area,'span','small')
|
||||
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='lib/images/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='lib/images/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
|
||||
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='images/lib/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='images/lib/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
|
||||
$dh(this.label_area);}
|
||||
if(!this.input_area){this.input_area=$a(this.wrapper,(this.with_label?'div':'span'));this.disp_area=$a(this.wrapper,(this.with_label?'div':'span'));}
|
||||
if(this.in_grid){if(this.label_area)$dh(this.label_area);}else{this.input_area.className='input_area';$y(this.wrapper,{marginBottom:'9px'});this.set_description();}
|
||||
@ -1581,7 +1608,7 @@ CurrencyField.prototype.validate=function(v){if(v==null||v=='')
|
||||
return 0;return flt(v,2);}
|
||||
CurrencyField.prototype.set_disp=function(val){var v=fmt_money(val);this.set_disp_html(v);}
|
||||
CurrencyField.prototype.onmake_input=function(){if(!this.input)return;this.input.onfocus=function(){if(flt(this.value)==0)this.select();}}
|
||||
function CheckField(){}CheckField.prototype=new Field();CheckField.prototype.validate=function(v){var v=parseInt(v);if(isNaN(v))return 0;return v;};CheckField.prototype.onmake=function(){this.checkimg=$a(this.disp_area,'div');var img=$a(this.checkimg,'img');img.src='lib/images/ui/tick.gif';$dh(this.checkimg);}
|
||||
function CheckField(){}CheckField.prototype=new Field();CheckField.prototype.validate=function(v){var v=parseInt(v);if(isNaN(v))return 0;return v;};CheckField.prototype.onmake=function(){this.checkimg=$a(this.disp_area,'div');var img=$a(this.checkimg,'img');img.src='images/lib/ui/tick.gif';$dh(this.checkimg);}
|
||||
CheckField.prototype.make_input=function(){var me=this;this.input=$a_input(this.input_area,'checkbox');$y(this.input,{width:"16px",border:'0px',margin:'2px'});$(this.input).click(function(){me.set(this.checked?1:0);me.run_trigger();})
|
||||
this.input.set_input=function(v){v=parseInt(v);if(isNaN(v))v=0;if(v)me.input.checked=true;else me.input.checked=false;}
|
||||
this.get_value=function(){return this.input.checked?1:0;}}
|
||||
@ -1878,11 +1905,11 @@ if(cur_frm.editable&&cur_frm.doc.docstatus>0){if(this.df.allow_on_submit&&cur_fr
|
||||
if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}}
|
||||
if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();}
|
||||
this.grid.refresh();}
|
||||
_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"lib/js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}}
|
||||
_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}}
|
||||
this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();}
|
||||
this.get_value=function(){return me.editor.getContent();}}else{wn.require('lib/js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('lib/js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());}
|
||||
else if(me.df.options=='Javascript'){wn.require('lib/js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());}
|
||||
else if(me.df.options=='Python'){wn.require('lib/js/lib/ace/mode-python.js');var PythonMode=require("ace/mode/python").Mode;me.editor.getSession().setMode(new PythonMode());}
|
||||
this.get_value=function(){return me.editor.getContent();}}else{wn.require('js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());}
|
||||
else if(me.df.options=='Javascript'){wn.require('js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());}
|
||||
else if(me.df.options=='Python'){wn.require('js/lib/ace/mode-python.js');var PythonMode=require("ace/mode/python").Mode;me.editor.getSession().setMode(new PythonMode());}
|
||||
this.input.set_input=function(v){me.setting_value=true;me.editor.getSession().setValue(v);me.setting_value=false;}
|
||||
this.get_value=function(){return me.editor.getSession().getValue();}
|
||||
$(cur_frm.wrapper).bind('render_complete',function(){me.editor.resize();me.editor.getSession().on('change',function(){if(me.setting_value)return;var val=me.get_value();if(locals[cur_frm.doctype][cur_frm.docname][me.df.fieldname]!=val){me.set(me.get_value());me.run_trigger();}})});}}
|
||||
@ -2127,7 +2154,7 @@ CommentList.prototype.run=function(){this.lst.run();}
|
||||
CommentList.prototype.make_input=function(){var me=this;this.input=$a(this.input_area,'textarea','',{height:'60px',width:'300px',fontSize:'14px'});this.btn=$btn($a(this.input_area,'div'),'Post',function(){me.add_comment();},{marginTop:'8px'});}
|
||||
CommentList.prototype.add_comment=function(){var me=this;var callback=function(input,dt,dn){me.lst.run();}
|
||||
wn.widgets.form.comments.add(this.input,cur_frm.docname,cur_frm.doctype,callback)}
|
||||
CommentList.prototype.make_lst=function(){if(!this.lst){wn.require('lib/js/legacy/widgets/listing.js');var l=new Listing('Comments',1);var me=this;l.colwidths=['100%'];l.opts.hide_export=1;l.opts.hide_print=1;l.opts.hide_refresh=1;l.opts.no_border=1;l.opts.hide_rec_label=0;l.opts.show_calc=0;l.opts.round_corners=0;l.opts.alt_cell_style={};l.opts.cell_style={padding:'3px'};l.no_rec_message='No comments yet. Be the first one to comment!';l.get_query=function(){this.query=repl("select t1.name, t1.comment, t1.comment_by, '', \
|
||||
CommentList.prototype.make_lst=function(){if(!this.lst){wn.require('js/listing.js');var l=new Listing('Comments',1);var me=this;l.colwidths=['100%'];l.opts.hide_export=1;l.opts.hide_print=1;l.opts.hide_refresh=1;l.opts.no_border=1;l.opts.hide_rec_label=0;l.opts.show_calc=0;l.opts.round_corners=0;l.opts.alt_cell_style={};l.opts.cell_style={padding:'3px'};l.no_rec_message='No comments yet. Be the first one to comment!';l.get_query=function(){this.query=repl("select t1.name, t1.comment, t1.comment_by, '', \
|
||||
t1.creation, t1.comment_doctype, t1.comment_docname, \
|
||||
ifnull(concat_ws(' ',ifnull(t2.first_name,''),ifnull(t2.middle_name,''),\
|
||||
ifnull(t2.last_name,'')),''), '', \
|
||||
@ -2208,28 +2235,23 @@ me.dialog.clear();me.dialog.show();}});
|
||||
/*
|
||||
* lib/js/wn/app.js
|
||||
*/
|
||||
wn.Application=Class.extend({init:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
|
||||
wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;}
|
||||
me.startup();}})}else{document.cookie="sid=Guest;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"
|
||||
this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
|
||||
console.log(wn.boot.error_messages)
|
||||
if(wn.boot.server_messages)
|
||||
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
|
||||
me.redirect_to_login();}})},redirect_to_login:function(){window.location.hash='';window.location.reload();},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
|
||||
msgprint(wn.boot.server_messages);this.set_globals();}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
|
||||
me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
|
||||
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
|
||||
<link rel="icon" href="'+link+'" type="image/x-icon">'
|
||||
$(favicon).appendTo('head');}})
|
||||
/*
|
||||
* js/app.js
|
||||
*/
|
||||
wn.provide('erpnext');erpnext.set_about=function(){wn.provide('wn.app');$.extend(wn.app,{name:'ERPNext',license:'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is',source:'https://github.com/webnotes/erpnext',publisher:'Web Notes Technologies Pvt Ltd, Mumbai',copyright:'© Web Notes Technologies Pvt Ltd',version:'2'});}
|
||||
wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand').html((wn.boot.website_settings.brand_html||'erpnext')+' <i class="icon-home icon-white navbar-icon-home" ></i>').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});});
|
||||
/*
|
||||
* erpnext/startup/startup.js
|
||||
*/
|
||||
var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
|
||||
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){if(inList(user_roles,'System Manager'))is_system_manager=1;}
|
||||
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
|
||||
if(user=='Guest'){if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
|
||||
if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}
|
||||
if(wn.boot.startup_code){eval(wn.boot.startup_code);}}else{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
|
||||
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(user!='Guest'){if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
|
||||
wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
|
||||
erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
|
||||
<a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup.show();}
|
||||
if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('<div class="expiry-info"> \
|
||||
@ -2238,9 +2260,11 @@ if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.
|
||||
(and remove this annoying banner). \
|
||||
</div>',{expiry_string:expiry_string}));}else if(diff<0){$('header').append(repl('<div class="expiry-info"> \
|
||||
This ERPNext subscription <b>has expired</b>. \
|
||||
</div>',{expiry_string:expiry_string}));}}}
|
||||
</div>',{expiry_string:expiry_string}));}}
|
||||
erpnext.set_about();if(wn.control_panel.custom_startup_code)
|
||||
eval(wn.control_panel.custom_startup_code);$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" href="http://erpnext.com" target="_blank"></a>')}
|
||||
eval(wn.control_panel.custom_startup_code);}
|
||||
$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
|
||||
href="http://erpnext.com" target="_blank"></a>')}
|
||||
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
|
||||
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
|
||||
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
|
||||
@ -2306,4 +2330,9 @@ hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);else if(cu
|
||||
{for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort])
|
||||
cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field],false);}
|
||||
else
|
||||
msgprint('Grid "'+fort+'" does not exists');}}}}})
|
||||
msgprint('Grid "'+fort+'" does not exists');}}}}})
|
||||
/*
|
||||
* conf.js
|
||||
*/
|
||||
wn.provide('erpnext');erpnext.set_about=function(){wn.provide('wn.app');$.extend(wn.app,{name:'ERPNext',license:'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is',source:'https://github.com/webnotes/erpnext',publisher:'Web Notes Technologies Pvt Ltd, Mumbai',copyright:'© Web Notes Technologies Pvt Ltd',version:'2'});}
|
||||
wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand').html((wn.boot.website_settings.brand_html||'erpnext')+' <i class="icon-home icon-white navbar-icon-home" ></i>').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});});
|
@ -71,7 +71,7 @@ wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px
|
||||
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i<options_list.length;i++){var v=options_list[i];value=v.value||v;label=v.label||v;$('<option>').html(label).attr('value',value).appendTo(this);}
|
||||
$(this).val(options_list[0].value||options_list[0]);}
|
||||
$.fn.set_working=function(){var ele=this.get(0);if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.disabled=1;ele.loading_img=$('<img src="lib/images/ui/button-load.gif" \
|
||||
$.fn.set_working=function(){var ele=this.get(0);if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.disabled=1;ele.loading_img=$('<img src="images/lib/ui/button-load.gif" \
|
||||
style="margin-left: 4px; margin-bottom: -2px; display: inline;" />').insertAfter(ele);}}
|
||||
$.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery);
|
||||
/*
|
||||
@ -88,18 +88,19 @@ wn.meta.docfield_list[df.parent].push(df);}});
|
||||
/*
|
||||
* lib/js/wn/misc/tools.js
|
||||
*/
|
||||
wn.markdown=function(txt){if(!wn.md2html){wn.require('lib/js/lib/showdown.js');wn.md2html=new Showdown.converter();}
|
||||
wn.markdown=function(txt){if(!wn.md2html){wn.require('js/lib/showdown.js');wn.md2html=new Showdown.converter();}
|
||||
return wn.md2html.makeHtml(txt);}
|
||||
/*
|
||||
* lib/js/wn/misc/user.js
|
||||
*/
|
||||
wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'}
|
||||
wn.user_info=function(uid){var def={'fullname':uid,'image':'images/lib/ui/no_img_m.gif'}
|
||||
if(!wn.boot.user_info)return def
|
||||
if(!wn.boot.user_info[uid])return def
|
||||
if(!wn.boot.user_info[uid].fullname)
|
||||
wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image)
|
||||
wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];}
|
||||
wn.provide('wn.user');$.extend(wn.user,{name:wn.boot.profile.name,has_role:function(rl){if(typeof rl=='string')rl=[rl];for(var i in rl){if(wn.boot.profile.roles.indexOf(rl[i])!=-1)
|
||||
wn.provide('wn.user');$.extend(wn.user,{name:(wn.boot?wn.boot.profile.name:'Guest'),has_role:function(rl){if(typeof rl=='string')
|
||||
rl=[rl];for(var i in rl){if((wn.boot?wn.boot.profile.roles:['Guest']).indexOf(rl[i])!=-1)
|
||||
return true;}},is_report_manager:function(){return wn.user.has_role(['Administrator','System Manager','Report Manager']);}})
|
||||
wn.session_alive=true;$(document).bind('mousemove',function(){wn.session_alive=true;if(wn.session_alive_timeout)
|
||||
clearTimeout(wn.session_alive_timeout);wn.session_alive_timeout=setTimeout('wn.session_alive=false;',30000);})
|
||||
@ -167,7 +168,7 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
|
||||
<div class="list-toolbar" style="display:inline-block; margin-right: 10px;">\
|
||||
</div>\
|
||||
<div style="display:inline-block; width: 24px; margin-left: 4px">\
|
||||
<img src="lib/images/ui/button-load.gif" \
|
||||
<img src="images/lib/ui/button-load.gif" \
|
||||
class="img-load"/></div>\
|
||||
</div><div style="clear:both"></div>\
|
||||
\
|
||||
@ -203,7 +204,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct
|
||||
/*
|
||||
* lib/js/wn/ui/filters.js
|
||||
*/
|
||||
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('lib/js/legacy/widgets/form/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
|
||||
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
|
||||
this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
|
||||
values.push(f.get_value());})
|
||||
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
|
||||
@ -253,88 +254,13 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('<span clas
|
||||
onclick="wn.set_route(\'List\', \'%(doctype)s\')">\
|
||||
<i class="icon-list icon-white"></i> %(doctype)s List\
|
||||
</span>',{doctype:doctype}));}
|
||||
/*
|
||||
* lib/js/wn/views/doclistview.js
|
||||
*/
|
||||
wn.provide('wn.views.doclistview');wn.provide('wn.doclistviews');wn.views.doclistview.show=function(doctype){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){wn.model.with_doctype(route[1],function(r){if(r&&r['403']){return;}
|
||||
new wn.views.DocListView(route[1]);});}}}
|
||||
wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=doctype;this.label=get_doctype_label(doctype);this.label=(this.label.toLowerCase().substr(-4)=='list')?this.label:(this.label+' List');this.make_page();this.setup();},make_page:function(){var me=this;var page_name=wn.get_route_str();var page=wn.container.add_page(page_name);wn.container.change_to(page_name);this.$page=$(page);this.$page.html(repl('<div class="layout-wrapper layout-wrapper-background">\
|
||||
<div class="appframe-area"></div>\
|
||||
<div class="layout-main-section">\
|
||||
<h1>%(label)s</h1>\
|
||||
<hr>\
|
||||
<div class="wnlist-area"><div class="help">Loading...</div></div>\
|
||||
</div>\
|
||||
<div class="layout-side-section">\
|
||||
<div class="stat-wrapper show-docstatus hide">\
|
||||
<h4>Show</h4>\
|
||||
<div><input data-docstatus="0" type="checkbox" checked="checked" /> Drafts</div>\
|
||||
<div><input data-docstatus="1" type="checkbox" checked="checked" /> Submitted</div>\
|
||||
<div><input data-docstatus="2" type="checkbox" /> Cancelled</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div style="clear: both"></div>\
|
||||
</div>',{label:this.label}));this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span>').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
|
||||
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
|
||||
this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
|
||||
%(description)s\
|
||||
<hr>\
|
||||
<p><button class="btn btn-info btn-small"\
|
||||
onclick="newdoc(\'%(doctype)s\');"\
|
||||
>Make a new %(doctype_label)s</button>\
|
||||
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
|
||||
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
|
||||
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
|
||||
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
|
||||
<div class="help small"><i>No records tagged.</i><br><br> \
|
||||
To add a tag, open the document and click on \
|
||||
"Add Tag" on the sidebar</div></div>');}
|
||||
return;}
|
||||
var label=wn.meta.docfield_map[this.doctype][field]?wn.meta.docfield_map[this.doctype][field].label:field;if(label=='_user_tags')label='Tags';var $w=$('<div class="stat-wrapper">\
|
||||
<h4>'+label+'</h4>\
|
||||
<div class="stat-grid">\
|
||||
</div>\
|
||||
</div>');stat=stat.sort(function(a,b){return b[1]-a[1]});var sum=0;$.each(stat,function(i,v){sum=sum+v[1];})
|
||||
$.each(stat,function(i,v){me.render_stat_item(i,v,sum,field).appendTo($w.find('.stat-grid'));});$w.appendTo(this.$page.find('.layout-side-section'));},render_stat_item:function(i,v,max,field){var me=this;var args={}
|
||||
args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$item=$(repl('<div class="stat-item">\
|
||||
<div class="stat-bar" style="width: %(width)s%"></div>\
|
||||
<div class="stat-label">\
|
||||
<a href="#" data-label="%(label)s" data-field="%(field)s">\
|
||||
%(label)s</a> \
|
||||
(%(count)s)</div>\
|
||||
</div>',args));this.setup_stat_item_click($item);return $item;},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}}
|
||||
this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#777'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});}
|
||||
if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;}
|
||||
if(typeof opts.content=='function'){opts.content(parent,data);}
|
||||
else if(opts.content=='name'){$(parent).append(repl('<a href="#!Form/%(doctype)s/%(name)s">%(name)s</a>',data));}
|
||||
else if(opts.content=='avatar'){$(parent).append(repl('<span class="avatar-small"><img src="%(avatar)s" \
|
||||
title="%(fullname)s"/></span>',data));}
|
||||
else if(opts.content=='check'){$(parent).append('<input class="list-delete" type="checkbox">');$(parent).find('input').data('name',data.name);}
|
||||
else if(opts.content=='docstatus'){$(parent).append(repl('<span class="docstatus"><i class="%(docstatus_icon)s" \
|
||||
title="%(docstatus_title)s"></i></span>',data));}
|
||||
else if(opts.content=='tags'){this.add_user_tags(parent,data);}
|
||||
else if(opts.content=='modified'){$(parent).append(data.when);}
|
||||
else if(opts.type=='bar-graph'){args={percent:data[opts.content],fully_delivered:(data[opts.content]>99?'bar-complete':''),label:opts.label}
|
||||
$(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(percent)s% %(label)s">\
|
||||
<span class="bar-inner %(fully_delivered)s" \
|
||||
style="width: %(percent)s%;"></span>\
|
||||
</span>',args));}
|
||||
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
||||
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
||||
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
||||
else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;data.when=dateutil.str_to_user(data.modified).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),data.modified.split(' ')[0]);if(diff==0){data.when='Today'}
|
||||
if(diff==1){data.when='Yesterday'}
|
||||
if(diff==2){data.when='2 days ago'}
|
||||
if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
|
||||
for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer">'
|
||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}})
|
||||
/*
|
||||
* lib/js/wn/views/pageview.js
|
||||
*/
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if(!locals.Page[name]){wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}else{callback();}},show:function(name){if(!name)name=wn.boot.home_page;wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if((locals.Page&&locals.Page[name])||name==window.home_page){callback();}else{wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}},show:function(name){if(!name)name=(wn.boot?wn.boot.home_page:'Login Page');wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
|
||||
wn.container.change_to(name);});}}
|
||||
wn.views.Page=Class.extend({init:function(name){this.name=name;var me=this;this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
|
||||
wn.views.Page=Class.extend({init:function(name,wrapper){this.name=name;var me=this;if(name==window.home_page){this.wrapper=document.getElementById('page-'+name);this.wrapper.title=document.title;this.wrapper.label=window.home_page;}else{this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');}
|
||||
this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
|
||||
wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html('<div class="layout-wrapper">\
|
||||
<h1>Not Found</h1><br>\
|
||||
<p>Sorry we were unable to find what you were looking for.</p>\
|
||||
@ -344,57 +270,13 @@ wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html(
|
||||
<p>Sorry you are not permitted to view this page.</p>\
|
||||
<p><a href="#">Go back to home</a></p>\
|
||||
</div>').toggle(false);};
|
||||
/*
|
||||
* lib/js/wn/views/formview.js
|
||||
*/
|
||||
wn.provide('wn.views.formview');wn.views.formview={show:function(dt,dn){if(wn.model.new_names[dn])
|
||||
dn=wn.model.new_names[dn];wn.model.with_doctype(dt,function(){wn.model.with_doc(dt,dn,function(dn,r){if(r&&r['403'])return;if(!(locals[dt]&&locals[dt][dn])){wn.container.change_to('404');return;}
|
||||
if(!wn.views.formview[dt]){wn.views.formview[dt]=wn.container.add_page('Form - '+dt);wn.views.formview[dt].frm=new _f.Frm(dt,wn.views.formview[dt]);}
|
||||
wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})},create:function(dt){var new_name=LocalDB.create(dt);wn.set_route('Form',dt,new_name);}}
|
||||
/*
|
||||
* lib/js/wn/views/reportview.js
|
||||
*/
|
||||
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t)){rb.dt.run();}}
|
||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||
wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportView(route[1],route[2]);}else{new wn.views.ReportHome();}}}}
|
||||
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname){var me=this;this.page_name=wn.get_route_str();this.import_slickgrid();this.doctype=doctype;this.docname=docname;this.tab_name='`tab'+doctype+'`';this.make_page();wn.model.with_doctype(doctype,function(){me.setup();if(docname){wn.model.with_doc('Report',docname,function(r){me.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.run();});}else{me.run();}});},import_slickgrid:function(){wn.require('lib/js/lib/slickgrid/slick.grid.css');wn.require('lib/js/lib/slickgrid/slick-default-theme.css');wn.require('lib/js/lib/slickgrid/jquery.event.drag.min.js');wn.require('lib/js/lib/slickgrid/slick.core.js');wn.require('lib/js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_full_column_name([this.sort_by_select.val()])
|
||||
+' '+this.sort_order_select.val()
|
||||
if(this.sort_by_next_select.val()){order_by+=', '+this.get_full_column_name([this.sort_by_next_select.val()])
|
||||
+' '+this.sort_order_next_select.val()}
|
||||
return order_by;},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){return{id:c[0],field:c[0],name:(wn.meta.docfield_map[c[1]||me.doctype][c[0]]?wn.meta.docfield_map[c[1]||me.doctype][c[0]].label:toTitle(c[0])),width:120}});},render_list:function(){var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
|
||||
<div class="sort-column"></div>\
|
||||
<div><select class="sort-order" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div>\
|
||||
<hr><p class="help">Then By (optional)</p>\
|
||||
<div class="sort-column-1"></div>\
|
||||
<div><select class="sort-order-1" style="margin-top: 10px; width: 60%;">\
|
||||
<option value="asc">Ascending</option>\
|
||||
<option value="desc">Descending</option>\
|
||||
</select></div><hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');this.sort_by_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column'),this.doctype).$select;this.sort_by_select.css('width','60%');this.sort_order_select=$(this.sort_dialog.body).find('.sort-order');this.sort_by_next_select=new wn.ui.FieldSelect($(this.sort_dialog.body).find('.sort-column-1'),this.doctype,null,true).$select;this.sort_by_next_select.css('width','60%');this.sort_order_next_select=$(this.sort_dialog.body).find('.sort-order-1');this.sort_by_select.val('modified');this.sort_order_select.val('desc');this.sort_by_next_select.val('');this.sort_order_next_select.val('desc');this.page.appframe.add_button('Sort By',function(){me.sort_dialog.show();},'icon-arrow-down');$(this.sort_dialog.body).find('.btn-info').click(function(){me.sort_dialog.hide();me.run();});},make_export:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Export',function(){var args=me.get_args();args.cmd='webnotes.widgets.doclistview.export_query'
|
||||
open_url_post(wn.request.url,args);},'icon-download-alt');}},make_save:function(){var me=this;if(wn.user.is_report_manager()){this.page.appframe.add_button('Save',function(){if(me.docname){var name=me.docname}else{var name=prompt('Select Report Name');if(!name){return;}}
|
||||
wn.call({method:'webnotes.widgets.doclistview.save_report',args:{name:name,doctype:me.doctype,json:JSON.stringify({filters:me.filter_list.get_filters(),columns:me.columns,sort_by:me.sort_by_select.val(),sort_order:me.sort_order_select.val(),sort_by_next:me.sort_by_next_select.val(),sort_order_next:me.sort_order_next_select.val()})},callback:function(r){if(r.exc)return;if(r.message!=me.docname)
|
||||
wn.set_route('Report2',me.doctype,r.message);}});},'icon-upload');}}});wn.ui.ColumnPicker=Class.extend({init:function(list){this.list=list;this.doctype=list.doctype;this.selects={};},show:function(columns){wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');var me=this;if(!this.dialog){this.dialog=new wn.ui.Dialog({title:'Pick Columns',width:'400'});}
|
||||
$(this.dialog.body).html('<div class="help">Drag to sort columns</div>\
|
||||
<div class="column-list"></div>\
|
||||
<div><button class="btn btn-small btn-add"><i class="icon-plus"></i>\
|
||||
Add Column</button></div>\
|
||||
<hr>\
|
||||
<div><button class="btn btn-small btn-info">Update</div>');$.each(columns,function(i,c){me.add_column(c);});$(this.dialog.body).find('.column-list').sortable();$(this.dialog.body).find('.btn-add').click(function(){me.add_column('name');});$(this.dialog.body).find('.btn-info').click(function(){me.dialog.hide();me.list.columns=[];$(me.dialog.body).find('select').each(function(){me.list.columns.push([$(this).val(),$(this).find('option:selected').attr('table')]);})
|
||||
me.list.run();});this.dialog.show();},add_column:function(c){var w=$('<div style="padding: 5px 5px 5px 35px; background-color: #eee; width: 70%; \
|
||||
margin-bottom: 10px; border-radius: 3px; cursor: move;">\
|
||||
<a class="close" style="margin-top: 5px;">×</a>\
|
||||
</div>').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val(c);w.find('.close').click(function(){$(this).parent().remove();});}});
|
||||
/*
|
||||
* lib/js/wn/request.js
|
||||
*/
|
||||
wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
throw"Incomplete Request";}}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){msgprint('Session Expired. Logging you out');if(!wn.app.logged_out)
|
||||
wn.app.logout();return;}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
|
||||
return;}
|
||||
if(r.server_messages)msgprint(r.server_messages)
|
||||
if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');}
|
||||
if(r.docs)LocalDB.sync(r.docs);}
|
||||
@ -408,7 +290,7 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f
|
||||
* lib/js/core.js
|
||||
*/
|
||||
if(!console){var console={log:function(txt){}}}
|
||||
wn.versions.check();$(document).bind('ready',function(){wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
|
||||
$(document).bind('ready',function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
|
||||
|
||||
/*
|
||||
* lib/js/legacy/globals.js
|
||||
@ -435,7 +317,7 @@ function is_null(v){if(v==null){return 1}else if(v==0){if((v+'').length>=1)retur
|
||||
function $s(ele,v,ftype,fopt){if(v==null)v='';if(ftype=='Text'||ftype=='Small Text'){ele.innerHTML=v?v.replace(/\n/g,'<br>'):'';}else if(ftype=='Date'){v=dateutil.str_to_user(v);if(v==null)v=''
|
||||
ele.innerHTML=v;}else if(ftype=='Link'&&fopt){ele.innerHTML='';doc_link(ele,fopt,v);}else if(ftype=='Currency'){ele.style.textAlign='right';if(is_null(v))
|
||||
ele.innerHTML='';else
|
||||
ele.innerHTML=fmt_money(v);}else if(ftype=='Int'){ele.style.textAlign='right';ele.innerHTML=v;}else if(ftype=='Check'){if(v)ele.innerHTML='<img src="lib/images/ui/tick.gif">';else ele.innerHTML='';}else{ele.innerHTML=v;}}
|
||||
ele.innerHTML=fmt_money(v);}else if(ftype=='Int'){ele.style.textAlign='right';ele.innerHTML=v;}else if(ftype=='Check'){if(v)ele.innerHTML='<img src="images/lib/ui/tick.gif">';else ele.innerHTML='';}else{ele.innerHTML=v;}}
|
||||
function clean_smart_quotes(s){if(s){s=s.replace(/\u2018/g,"'");s=s.replace(/\u2019/g,"'");s=s.replace(/\u201c/g,'"');s=s.replace(/\u201d/g,'"');s=s.replace(/\u2013/g,'-');s=s.replace(/\u2014/g,'--');}
|
||||
return s;}
|
||||
function copy_dict(d){var n={};for(var k in d)n[k]=d[k];return n;}
|
||||
@ -516,8 +398,8 @@ var time_to_ampm=wn.datetime.time_to_ampm;var time_to_hhmm=wn.datetime.time_to_h
|
||||
* lib/js/legacy/utils/dom.js
|
||||
*/
|
||||
wn.tinymce={add_simple:function(ele,height){if(ele.myid){tinyMCE.execCommand('mceAddControl',true,ele.myid);return;}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='lib/images/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='images/lib/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
span.set_working=function(){this.disabled=1;$di(this.loading_img);}
|
||||
span.done_working=function(){this.disabled=0;$dh(this.loading_img);}
|
||||
return span;}}
|
||||
@ -622,7 +504,7 @@ if(!msg_dialog){msg_dialog=new Dialog(500,200,"Message");msg_dialog.make_body([[
|
||||
msg_dialog.onhide=function(){msg_dialog.msg_area.innerHTML='';$dh(msg_dialog.msg_icon);if(msg_dialog.custom_onhide)msg_dialog.custom_onhide();}
|
||||
$y(msg_dialog.rows['Msg'],{fontSize:'14px',lineHeight:'1.5em',padding:'16px'})
|
||||
var t=make_table(msg_dialog.rows['Msg'],1,2,'100%',['20px','250px'],{padding:'2px',verticalAlign:'Top'});msg_dialog.msg_area=$td(t,0,1);msg_dialog.msg_icon=$a($td(t,0,0),'img');}
|
||||
if(!msg_dialog.display)msg_dialog.show();var has_msg=msg_dialog.msg_area.innerHTML?1:0;var m=$a(msg_dialog.msg_area,'div','');if(has_msg)$y(m,{marginTop:'4px'});$dh(msg_dialog.msg_icon);if(msg.substr(0,6).toLowerCase()=='error:'){msg_dialog.msg_icon.src='lib/images/icons/error.gif';$di(msg_dialog.msg_icon);msg=msg.substr(6);}else if(msg.substr(0,8).toLowerCase()=='message:'){msg_dialog.msg_icon.src='lib/images/icons/application.gif';$di(msg_dialog.msg_icon);msg=msg.substr(8);}else if(msg.substr(0,3).toLowerCase()=='ok:'){msg_dialog.msg_icon.src='lib/images/icons/accept.gif';$di(msg_dialog.msg_icon);msg=msg.substr(3);}
|
||||
if(!msg_dialog.display)msg_dialog.show();var has_msg=msg_dialog.msg_area.innerHTML?1:0;var m=$a(msg_dialog.msg_area,'div','');if(has_msg)$y(m,{marginTop:'4px'});$dh(msg_dialog.msg_icon);if(msg.substr(0,6).toLowerCase()=='error:'){msg_dialog.msg_icon.src='images/lib/icons/error.gif';$di(msg_dialog.msg_icon);msg=msg.substr(6);}else if(msg.substr(0,8).toLowerCase()=='message:'){msg_dialog.msg_icon.src='images/lib/icons/application.gif';$di(msg_dialog.msg_icon);msg=msg.substr(8);}else if(msg.substr(0,3).toLowerCase()=='ok:'){msg_dialog.msg_icon.src='images/lib/icons/accept.gif';$di(msg_dialog.msg_icon);msg=msg.substr(3);}
|
||||
m.innerHTML=replace_newlines(msg);if(m.offsetHeight>200){$y(m,{height:'200px',width:'400px',overflow:'auto'})}
|
||||
msg_dialog.custom_onhide=callback;}
|
||||
var growl_area;function show_alert(txt,id){if(!growl_area){if(!$('#dialog-container').length){$('<div id="dialog-container">').appendTo('body');}
|
||||
@ -652,7 +534,7 @@ opts.parent.appframe=new wn.ui.AppFrame($(opts.parent).find('.layout-appframe'))
|
||||
/*
|
||||
* lib/js/wn/ui/dialog.js
|
||||
*/
|
||||
wn.widgets.FieldGroup=function(){this.first_button=false;this.make_fields=function(body,fl){if(!window.make_field){wn.require('lib/css/legacy/fields.css');wn.require('lib/js/legacy/widgets/form/fields.js');wn.require('lib/js/wn/ui/button.js');}
|
||||
wn.widgets.FieldGroup=function(){this.first_button=false;this.make_fields=function(body,fl){if(!window.make_field){wn.require('css/fields.css');wn.require('js/fields.js');}
|
||||
$y(this.body,{padding:'11px'});this.fields_dict={};for(var i=0;i<fl.length;i++){var df=fl[i];var div=$a(body,'div','',{margin:'6px 0px'})
|
||||
f=make_field(df,null,div,null);f.not_in_form=1;this.fields_dict[df.fieldname]=f
|
||||
f.refresh();if(df.fieldtype=='Button'&&!this.first_button){$(f.input).addClass('btn-info');this.first_button=true;}}}
|
||||
@ -809,28 +691,23 @@ if(errfld.length)msgprint('<b>Mandatory fields required in '+
|
||||
/*
|
||||
* lib/js/wn/app.js
|
||||
*/
|
||||
wn.Application=Class.extend({init:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
|
||||
wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;}
|
||||
me.startup();}})}else{document.cookie="sid=Guest;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"
|
||||
this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages)
|
||||
console.log(wn.boot.error_messages)
|
||||
if(wn.boot.server_messages)
|
||||
msgprint(wn.boot.server_messages);this.set_globals();},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.user.name!='Guest'){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
|
||||
me.redirect_to_login();}})},redirect_to_login:function(){window.location.hash='';window.location.reload();},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
|
||||
msgprint(wn.boot.server_messages);this.set_globals();}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
|
||||
me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
|
||||
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
|
||||
<link rel="icon" href="'+link+'" type="image/x-icon">'
|
||||
$(favicon).appendTo('head');}})
|
||||
/*
|
||||
* js/app.js
|
||||
*/
|
||||
wn.provide('erpnext');erpnext.set_about=function(){wn.provide('wn.app');$.extend(wn.app,{name:'ERPNext',license:'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is',source:'https://github.com/webnotes/erpnext',publisher:'Web Notes Technologies Pvt Ltd, Mumbai',copyright:'© Web Notes Technologies Pvt Ltd',version:'2'});}
|
||||
wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand').html((wn.boot.website_settings.brand_html||'erpnext')+' <i class="icon-home icon-white navbar-icon-home" ></i>').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});});
|
||||
/*
|
||||
* erpnext/startup/startup.js
|
||||
*/
|
||||
var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
|
||||
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){if(inList(user_roles,'System Manager'))is_system_manager=1;}
|
||||
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
|
||||
if(user=='Guest'){if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
|
||||
if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}
|
||||
if(wn.boot.startup_code){eval(wn.boot.startup_code);}}else{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
|
||||
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(user!='Guest'){if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
|
||||
wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
|
||||
erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
|
||||
<a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup.show();}
|
||||
if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('<div class="expiry-info"> \
|
||||
@ -839,9 +716,11 @@ if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.
|
||||
(and remove this annoying banner). \
|
||||
</div>',{expiry_string:expiry_string}));}else if(diff<0){$('header').append(repl('<div class="expiry-info"> \
|
||||
This ERPNext subscription <b>has expired</b>. \
|
||||
</div>',{expiry_string:expiry_string}));}}}
|
||||
</div>',{expiry_string:expiry_string}));}}
|
||||
erpnext.set_about();if(wn.control_panel.custom_startup_code)
|
||||
eval(wn.control_panel.custom_startup_code);$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" href="http://erpnext.com" target="_blank"></a>')}
|
||||
eval(wn.control_panel.custom_startup_code);}
|
||||
$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
|
||||
href="http://erpnext.com" target="_blank"></a>')}
|
||||
erpnext.update_messages=function(reset){if(inList(['Guest'],user)||!wn.session_alive){return;}
|
||||
if(!reset){var set_messages=function(r){if(!r.exc){erpnext.toolbar.set_new_comments(r.message.unread_messages);var show_in_circle=function(parent_id,msg){var parent=$('#'+parent_id);if(parent){if(msg){parent.find('span:first').text(msg);parent.toggle(true);}else{parent.toggle(false);}}}
|
||||
show_in_circle('unread_messages',r.message.unread_messages.length);show_in_circle('open_support_tickets',r.message.open_support_tickets);show_in_circle('things_todo',r.message.things_todo);show_in_circle('todays_events',r.message.todays_events);}else{clearInterval(wn.updates.id);}}
|
||||
@ -854,30 +733,7 @@ wn.call({method:'website.send_message',args:opts,callback:function(r){if(opts.bt
|
||||
if(opts.callback)opts.callback(r)}});}
|
||||
erpnext.hide_naming_series=function(){if(cur_frm.fields_dict.naming_series){hide_field('naming_series');if(cur_frm.doc.__islocal){unhide_field('naming_series');}}}
|
||||
/*
|
||||
* erpnext/website/js/topbar.js
|
||||
* conf.js
|
||||
*/
|
||||
wn.provide('erpnext.navbar');erpnext.navbar.Navbar=Class.extend({init:function(){this.make();$('.brand').html(wn.boot.website_settings.brand_html||sys_defaults.company);this.make_items();$('.dropdown-toggle').dropdown();},make:function(){$('header').append('<div class="navbar navbar-fixed-top">\
|
||||
<div class="navbar-inner">\
|
||||
<div class="container">\
|
||||
<a class="brand">[brand]</a>\
|
||||
<ul class="nav">\
|
||||
</ul>\
|
||||
<img src="lib/images/ui/spinner.gif" id="spinner"/>\
|
||||
<ul class="nav pull-right">\
|
||||
<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>\
|
||||
</ul>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>');$('.brand').attr('href','#!'+(wn.boot.website_settings.home_page||'Login Page'))},make_items:function(){var items=wn.boot.website_menus;for(var i=0;i<items.length;i++){var item=items[i];if(!item.parent_label&&item.parentfield=='top_bar_items'){erpnext.header_link_settings(item);$('header .nav:first').append(repl('<li data-label="%(label)s">\
|
||||
<a href="%(route)s" %(target)s>%(label)s</a></li>',item));}}
|
||||
for(var i=0;i<items.length;i++){var item=items[i];if(item.parent_label&&item.parentfield=='top_bar_items'){$parent_li=$(repl('header li[data-label="%(parent_label)s"]',item));if(!$parent_li.hasClass('dropdown')){$parent_li.addClass('dropdown');$parent_li.find('a:first').addClass('dropdown-toggle').attr('data-toggle','dropdown').attr('href','').append('<b class="caret"></b>').click(function(){return false;});$parent_li.append('<ul class="dropdown-menu"></ul>');}
|
||||
erpnext.header_link_settings(item);$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
|
||||
<a href="%(route)s" %(target)s>%(label)s</a></li>',item))}}}});erpnext.Footer=Class.extend({init:function(){if(!wn.boot.website_settings.copyright){wn.boot.website_settings.copyright=sys_defaults.company;}
|
||||
if(!wn.boot.website_settings.address){wn.boot.website_settings.address='';}
|
||||
$('footer').html(repl('<div class="web-footer">\
|
||||
<div class="web-footer-menu"><ul></ul></div>\
|
||||
<div class="web-footer-copyright">© %(copyright)s</div>\
|
||||
</div>',wn.boot.website_settings));this.make_items();},make_items:function(){var items=wn.boot.website_menus
|
||||
for(var i=0;i<items.length;i++){var item=items[i];if(!item.parent_label&&item.parentfield=='footer_items'){erpnext.header_link_settings(item);$('.web-footer-menu ul').append(repl('<li><a href="%(route)s" %(target)s\
|
||||
data-label="%(label)s">%(label)s</a></li>',item))}}}});erpnext.header_link_settings=function(item){item.route=item.url||item.custom_page;if(item.route&&item.route.substr(0,4)=='http'){item.target='target="_blank"';}else{item.target='';item.route='#!'+item.route;}}
|
||||
$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.Navbar();})
|
||||
wn.provide('erpnext');erpnext.set_about=function(){wn.provide('wn.app');$.extend(wn.app,{name:'ERPNext',license:'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is',source:'https://github.com/webnotes/erpnext',publisher:'Web Notes Technologies Pvt Ltd, Mumbai',copyright:'© Web Notes Technologies Pvt Ltd',version:'2'});}
|
||||
wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand').html((wn.boot.website_settings.brand_html||'erpnext')+' <i class="icon-home icon-white navbar-icon-home" ></i>').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});});
|
211
public/js/fields.js
Normal file
@ -0,0 +1,211 @@
|
||||
|
||||
/*
|
||||
* lib/js/legacy/widgets/form/fields.js
|
||||
*/
|
||||
var no_value_fields=['Section Break','Column Break','HTML','Table','FlexTable','Button','Image'];var codeid=0;var code_editors={};function Field(){this.with_label=1;}
|
||||
Field.prototype.make_body=function(){var ischk=(this.df.fieldtype=='Check'?1:0);if(this.parent)
|
||||
this.wrapper=$a(this.parent,(this.with_label?'div':'span'));else
|
||||
this.wrapper=document.createElement((this.with_label?'div':'span'));this.label_area=$a(this.wrapper,'div','',{margin:'0px 0px 2px 0px'});if(ischk&&!this.in_grid){this.input_area=$a(this.label_area,'span','',{marginRight:'4px'});this.disp_area=$a(this.label_area,'span','',{marginRight:'4px'});}
|
||||
if(this.with_label){this.label_span=$a(this.label_area,'span','small')
|
||||
this.label_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 4px'});$dh(this.label_icon);this.label_icon.src='images/lib/icons/error.gif';this.label_icon.title='Mandatory value needs to be entered';this.suggest_icon=$a(this.label_area,'img','',{margin:'-3px 4px -3px 0px'});$dh(this.suggest_icon);this.suggest_icon.src='images/lib/icons/bullet_arrow_down.png';this.suggest_icon.title='With suggestions';}else{this.label_span=$a(this.label_area,'span','',{marginRight:'4px'})
|
||||
$dh(this.label_area);}
|
||||
if(!this.input_area){this.input_area=$a(this.wrapper,(this.with_label?'div':'span'));this.disp_area=$a(this.wrapper,(this.with_label?'div':'span'));}
|
||||
if(this.in_grid){if(this.label_area)$dh(this.label_area);}else{this.input_area.className='input_area';$y(this.wrapper,{marginBottom:'9px'});this.set_description();}
|
||||
if(this.onmake)this.onmake();}
|
||||
Field.prototype.set_max_width=function(){var no_max=['Code','Text Editor','Text','Table','HTML']
|
||||
if(this.wrapper&&this.layout_cell&&this.layout_cell.parentNode.cells&&this.layout_cell.parentNode.cells.length==1&&!in_list(no_max,this.df.fieldtype)){$y(this.wrapper,{paddingRight:'50%'});}}
|
||||
Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.label!=this.df.label){this.label_span.innerHTML=this.df.label;this.label=this.df.label;}}
|
||||
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help small','',this.df.description)
|
||||
if(in_list(['Text Editor','Code'],this.df.fieldtype))
|
||||
$(this.desc_area).addClass('help small');}}
|
||||
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
|
||||
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE])ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
|
||||
ret='None';if(cint(this.df.hidden))
|
||||
ret='None';if(ret=='Write'&&cint(cur_frm.doc.docstatus)>0)ret='Read';var a_o_s=cint(this.df.allow_on_submit);if(a_o_s&&(this.in_grid||(this.frm&&this.frm.not_in_container))){a_o_s=null;if(this.in_grid)a_o_s=this.grid.field.df.allow_on_submit;if(this.frm&&this.frm.not_in_container){a_o_s=cur_grid.field.df.allow_on_submit;}}
|
||||
if(cur_frm.editable&&a_o_s&&cint(cur_frm.doc.docstatus)>0&&!this.df.hidden){tmp_perm=get_perm(cur_frm.doctype,cur_frm.docname,1);if(tmp_perm[this.df.permlevel]&&tmp_perm[this.df.permlevel][WRITE])ret='Write';}
|
||||
return ret;}
|
||||
Field.prototype.set_style_mandatory=function(add){if(add){$(this.txt?this.txt:this.input).addClass('input-mandatory');if(this.disp_area)$(this.disp_area).addClass('input-mandatory');}else{$(this.txt?this.txt:this.input).removeClass('input-mandatory');if(this.disp_area)$(this.disp_area).removeClass('input-mandatory');}}
|
||||
Field.prototype.refresh_mandatory=function(){if(this.in_filter)return;if(this.df.reqd){if(this.label_area)this.label_area.style.color="#d22";this.set_style_mandatory(1);}else{if(this.label_area)this.label_area.style.color="#222";this.set_style_mandatory(0);}
|
||||
this.refresh_label_icon()
|
||||
this.set_reqd=this.df.reqd;}
|
||||
Field.prototype.refresh_display=function(){if(!this.current_status||this.current_status!=this.disp_status){if(this.disp_status=='Write'){if(this.make_input&&(!this.input)){this.make_input();if(this.onmake_input)this.onmake_input();}
|
||||
if(this.show)this.show()
|
||||
else{$ds(this.wrapper);}
|
||||
if(this.input){$ds(this.input_area);$dh(this.disp_area);if(this.input.refresh)this.input.refresh();}else{$dh(this.input_area);$ds(this.disp_area);}}else if(this.disp_status=='Read'){if(this.show)this.show()
|
||||
else{$ds(this.wrapper);}
|
||||
$dh(this.input_area);$ds(this.disp_area);}else{if(this.hide)this.hide();else $dh(this.wrapper);}
|
||||
this.current_status=this.disp_status;}}
|
||||
Field.prototype.refresh=function(){this.disp_status=this.get_status();if(this.in_grid&&this.table_refresh&&this.disp_status=='Write')
|
||||
{this.table_refresh();return;}
|
||||
this.set_label();this.refresh_display();if(this.onrefresh)
|
||||
this.onrefresh();if(this.input){if(this.input.refresh)this.input.refresh(this.df);}
|
||||
if(this.wrapper){this.wrapper.fieldobj=this;$(this.wrapper).trigger('refresh');}
|
||||
if(!this.not_in_form)
|
||||
this.set_input(_f.get_value(this.doctype,this.docname,this.df.fieldname));this.refresh_mandatory();this.set_max_width();}
|
||||
Field.prototype.refresh_label_icon=function(){if(this.df.reqd){if(this.get_value&&is_null(this.get_value())){if(this.label_icon)$ds(this.label_icon);$(this.txt?this.txt:this.input).addClass('field-to-update')}else{if(this.label_icon)$dh(this.label_icon);$(this.txt?this.txt:this.input).removeClass('field-to-update')}}}
|
||||
Field.prototype.set=function(val){if(this.not_in_form)
|
||||
return;if((!this.docname)&&this.grid){this.docname=this.grid.add_newrow();}
|
||||
var set_val=val;if(this.validate)set_val=this.validate(val);_f.set_value(this.doctype,this.docname,this.df.fieldname,set_val);this.value=val;}
|
||||
Field.prototype.set_input=function(val){this.value=val;if(this.input&&this.input.set_input){if(val==null)this.input.set_input('');else this.input.set_input(val);}
|
||||
var disp_val=val;if(val==null)disp_val='';this.set_disp(disp_val);}
|
||||
Field.prototype.run_trigger=function(){this.refresh_label_icon();if(this.df.reqd&&this.get_value&&!is_null(this.get_value())&&this.set_as_error)
|
||||
this.set_as_error(0);if(this.not_in_form){return;}
|
||||
if(cur_frm.cscript[this.df.fieldname])
|
||||
cur_frm.runclientscript(this.df.fieldname,this.doctype,this.docname);cur_frm.refresh_dependency();}
|
||||
Field.prototype.set_disp_html=function(t){if(this.disp_area){$(this.disp_area).addClass('disp_area');this.disp_area.innerHTML=(t==null?'':t);if(!t)$(this.disp_area).addClass('disp_area_no_val');}}
|
||||
Field.prototype.set_disp=function(val){this.set_disp_html(val);}
|
||||
Field.prototype.set_as_error=function(set){if(this.in_grid||this.in_filter)return;var w=this.txt?this.txt:this.input;if(set){$y(w,{border:'2px solid RED'});}else{$y(w,{border:'1px solid #888'});}}
|
||||
Field.prototype.activate=function(docname){this.docname=docname;this.refresh();if(this.input){var v=_f.get_value(this.doctype,this.docname,this.df.fieldname);this.last_value=v;if(this.input.onchange&&this.input.get_value&&this.input.get_value()!=v){if(this.validate)
|
||||
this.input.set_value(this.validate(v));else
|
||||
this.input.set_value((v==null)?'':v);if(this.format_input)
|
||||
this.format_input();}
|
||||
if(this.input.focus){try{this.input.focus();}catch(e){}}}
|
||||
if(this.txt){try{this.txt.focus();}catch(e){}
|
||||
this.txt.field_object=this;}}
|
||||
function DataField(){}DataField.prototype=new Field();DataField.prototype.make_input=function(){var me=this;this.input=$a_input(this.input_area,this.df.fieldtype=='Password'?'password':'text');this.get_value=function(){var v=this.input.value;if(this.validate)
|
||||
v=this.validate(v);return v;}
|
||||
this.input.name=this.df.fieldname;$(this.input).change(function(){me.set_value(me.get_value&&me.get_value()||$(this.input).val());});this.set_value=function(val){if(!me.last_value)me.last_value='';if(me.validate){val=me.validate(val);me.input.value=val==undefined?'':val;}
|
||||
me.set(val);if(me.format_input)
|
||||
me.format_input();if(in_list(['Currency','Float','Int'],me.df.fieldtype)){if(flt(me.last_value)==flt(val)){me.last_value=val;return;}}
|
||||
me.last_value=val;me.run_trigger();}
|
||||
this.input.set_input=function(val){if(val==null)val='';me.input.value=val;if(me.format_input)me.format_input();}
|
||||
if(this.df.options=='Suggest'){if(this.suggest_icon)$di(this.suggest_icon);$(me.input).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':repl('SELECT DISTINCT `%(fieldname)s` FROM \
|
||||
`tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50',{fieldname:me.df.fieldname,dt:me.df.parent})},callback:function(r){response(r.results);}});}});}}
|
||||
DataField.prototype.validate=function(v){if(this.df.options=='Phone'){if(v+''=='')return'';v1=''
|
||||
v=v.replace(/ /g,'').replace(/-/g,'').replace(/\(/g,'').replace(/\)/g,'');if(v&&v.substr(0,1)=='+'){v1='+';v=v.substr(1);}
|
||||
if(v&&v.substr(0,2)=='00'){v1+='00';v=v.substr(2);}
|
||||
if(v&&v.substr(0,1)=='0'){v1+='0';v=v.substr(1);}
|
||||
v1+=cint(v)+'';return v1;}else if(this.df.options=='Email'){if(v+''=='')return'';if(!validate_email(v)){msgprint(this.df.label+': '+v+' is not a valid email id');return'';}else
|
||||
return v;}else{return v;}}
|
||||
DataField.prototype.onrefresh=function(){if(this.input&&this.df.colour){var col='#'+this.df.colour.split(':')[1];$bg(this.input,col);}}
|
||||
function ReadOnlyField(){}
|
||||
ReadOnlyField.prototype=new Field();function HTMLField(){}
|
||||
HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){this.disp_area.innerHTML=val;}
|
||||
HTMLField.prototype.set_input=function(val){if(val)this.set_disp(val);}
|
||||
HTMLField.prototype.onrefresh=function(){this.set_disp(this.df.options?this.df.options:'');}
|
||||
var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=wn.control_panel.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell)
|
||||
_f.cur_grid_cell.grid.cell_deselect();}});var me=this;me.input.onchange=function(){if(this.value==null)this.value='';if(!this.not_in_form)
|
||||
me.set(dateutil.user_to_str(me.input.value));me.run_trigger();}
|
||||
me.input.set_input=function(val){if(val==null)val='';else val=dateutil.str_to_user(val);me.input.value=val;}
|
||||
me.get_value=function(){if(me.input.value)
|
||||
return dateutil.user_to_str(me.input.value);}}
|
||||
DateField.prototype.set_disp=function(val){var v=dateutil.str_to_user(val);if(v==null)v='';this.set_disp_html(v);}
|
||||
DateField.prototype.validate=function(v){if(!v)return;var me=this;this.clear=function(){msgprint("Date must be in format "+this.user_fmt);me.input.set_input('');return'';}
|
||||
var t=v.split('-');if(t.length!=3){return this.clear();}
|
||||
else if(cint(t[1])>12||cint(t[1])<1){return this.clear();}
|
||||
else if(cint(t[2])>31||cint(t[2])<1){return this.clear();}
|
||||
return v;};function LinkField(){}LinkField.prototype=new Field();LinkField.prototype.make_input=function(){var me=this;if(me.df.no_buttons){this.txt=$a(this.input_area,'input');this.input=this.txt;}else{makeinput_popup(this,'icon-search','icon-play','icon-plus');me.setup_buttons();me.onrefresh=function(){if(me.can_create&&cur_frm.doc.docstatus==0)
|
||||
$(me.btn2).css('display','inline-block');else $dh(me.btn2);}}
|
||||
me.txt.field_object=this;me.input.set_input=function(val){if(val==undefined)val='';me.txt.value=val;}
|
||||
me.get_value=function(){return me.txt.value;}
|
||||
$(me.txt).autocomplete({source:function(request,response){wn.call({method:'webnotes.widgets.search.search_link',args:{'txt':request.term,'dt':me.df.options,'query':me.get_custom_query()},callback:function(r){response(r.results);},});},select:function(event,ui){me.set_input_value(ui.item.value);}}).data('autocomplete')._renderItem=function(ul,item){return $('<li></li>').data('item.autocomplete',item).append(repl('<a>%(label)s<br><span style="font-size:10px">%(info)s</span></a>',item)).appendTo(ul);};$(this.txt).change(function(){if(!$(this).val()){if(selector&&selector.display)
|
||||
return;me.set_input_value('');}})}
|
||||
LinkField.prototype.get_custom_query=function(){this.set_get_query();if(this.get_query){if(cur_frm)
|
||||
var doc=locals[cur_frm.doctype][cur_frm.docname];return this.get_query(doc,this.doctype,this.docname);}}
|
||||
LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
|
||||
if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
|
||||
me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
|
||||
_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
|
||||
LinkField.prototype.set_input_value=function(val){var me=this;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
|
||||
if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
|
||||
me.set(val);if(_f.cur_grid_cell)
|
||||
_f.cur_grid_cell.grid.cell_deselect();if(locals[me.doctype][me.docname][me.df.fieldname]&&!val){me.run_trigger();return;}
|
||||
var fetch='';if(cur_frm.fetch_dict[me.df.fieldname])
|
||||
fetch=cur_frm.fetch_dict[me.df.fieldname].columns.join(', ');$c('webnotes.widgets.form.utils.validate_link',{'value':val,'options':me.df.options,'fetch':fetch},function(r,rt){if(r.message=='Ok'){if($(me.txt).val()!=val){if((me.grid&&!from_selector)||(!me.grid)){$(me.txt).val(val);}}
|
||||
if(r.fetch_values)
|
||||
me.set_fetch_values(r.fetch_values);me.run_trigger();}else{var astr='';if(in_list(profile.can_create,me.df.options))astr=repl('<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s',{dt:me.df.options,dtl:get_doctype_label(me.df.options)})
|
||||
msgprint(repl('error:<b>%(val)s</b> is not a valid %(dt)s.<br><br>You must first create a new %(dt)s <b>%(val)s</b> and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s',{val:me.txt.value,dt:get_doctype_label(me.df.options),add:astr}));me.txt.value='';me.set('');}});}
|
||||
LinkField.prototype.set_fetch_values=function(fetch_values){var fl=cur_frm.fetch_dict[this.df.fieldname].fields;var changed_fields=[];for(var i=0;i<fl.length;i++){if(locals[this.doctype][this.docname][fl[i]]!=fetch_values[i]){locals[this.doctype][this.docname][fl[i]]=fetch_values[i];if(!this.grid){refresh_field(fl[i]);changed_fields.push(fl[i]);}}}
|
||||
for(i=0;i<changed_fields.length;i++){if(cur_frm.fields_dict[changed_fields[i]])
|
||||
cur_frm.fields_dict[changed_fields[i]].run_trigger();}
|
||||
if(this.grid)this.grid.refresh();}
|
||||
LinkField.prototype.set_get_query=function(){if(this.get_query)return;if(this.grid){var f=this.grid.get_field(this.df.fieldname);if(f.get_query)this.get_query=f.get_query;}}
|
||||
LinkField.prototype.set_disp=function(val){var t=null;if(val)t="<a href=\'javascript:loaddoc(\""+this.df.options+"\", \""+val+"\")\'>"+val+"</a>";this.set_disp_html(t);}
|
||||
function IntField(){}IntField.prototype=new DataField();IntField.prototype.validate=function(v){if(isNaN(parseInt(v)))return null;return cint(v);};IntField.prototype.format_input=function(){if(this.input.value==null)this.input.value='';}
|
||||
function FloatField(){}FloatField.prototype=new DataField();FloatField.prototype.validate=function(v){var v=parseFloat(v);if(isNaN(v))
|
||||
return null;return v;};FloatField.prototype.format_input=function(){if(this.input.value==null)this.input.value='';}
|
||||
function CurrencyField(){}CurrencyField.prototype=new DataField();CurrencyField.prototype.format_input=function(){var v=fmt_money(this.input.value);if(this.not_in_form){if(!flt(this.input.value))v='';}
|
||||
this.input.value=v;}
|
||||
CurrencyField.prototype.validate=function(v){if(v==null||v=='')
|
||||
return 0;return flt(v,2);}
|
||||
CurrencyField.prototype.set_disp=function(val){var v=fmt_money(val);this.set_disp_html(v);}
|
||||
CurrencyField.prototype.onmake_input=function(){if(!this.input)return;this.input.onfocus=function(){if(flt(this.value)==0)this.select();}}
|
||||
function CheckField(){}CheckField.prototype=new Field();CheckField.prototype.validate=function(v){var v=parseInt(v);if(isNaN(v))return 0;return v;};CheckField.prototype.onmake=function(){this.checkimg=$a(this.disp_area,'div');var img=$a(this.checkimg,'img');img.src='images/lib/ui/tick.gif';$dh(this.checkimg);}
|
||||
CheckField.prototype.make_input=function(){var me=this;this.input=$a_input(this.input_area,'checkbox');$y(this.input,{width:"16px",border:'0px',margin:'2px'});$(this.input).click(function(){me.set(this.checked?1:0);me.run_trigger();})
|
||||
this.input.set_input=function(v){v=parseInt(v);if(isNaN(v))v=0;if(v)me.input.checked=true;else me.input.checked=false;}
|
||||
this.get_value=function(){return this.input.checked?1:0;}}
|
||||
CheckField.prototype.set_disp=function(val){if(val){$ds(this.checkimg);}
|
||||
else{$dh(this.checkimg);}}
|
||||
function TextField(){}TextField.prototype=new Field();TextField.prototype.set_disp=function(val){this.disp_area.innerHTML=replace_newlines(val);}
|
||||
TextField.prototype.make_input=function(){var me=this;if(this.in_grid)
|
||||
return;this.input=$a(this.input_area,'textarea');if(this.df.fieldtype=='Small Text')
|
||||
this.input.style.height="80px";this.input.set_input=function(v){me.input.value=v;}
|
||||
this.input.onchange=function(){me.set(me.input.value);me.run_trigger();}
|
||||
this.get_value=function(){return this.input.value;}}
|
||||
var text_dialog;function make_text_dialog(){var d=new Dialog(520,410,'Edit Text');d.make_body([['Text','Enter Text'],['HTML','Description'],['Button','Update']]);d.widgets['Update'].onclick=function(){var t=this.dialog;t.field.set(t.widgets['Enter Text'].value);t.hide();}
|
||||
d.onshow=function(){this.widgets['Enter Text'].style.height='300px';var v=_f.get_value(this.field.doctype,this.field.docname,this.field.df.fieldname);this.widgets['Enter Text'].value=v==null?'':v;this.widgets['Enter Text'].focus();this.widgets['Description'].innerHTML=''
|
||||
if(this.field.df.description)
|
||||
$a(this.widgets['Description'],'div','help small','',this.field.df.description);}
|
||||
d.onhide=function(){if(_f.cur_grid_cell)
|
||||
_f.cur_grid_cell.grid.cell_deselect();}
|
||||
text_dialog=d;}
|
||||
TextField.prototype.table_refresh=function(){if(!this.text_dialog)
|
||||
make_text_dialog();text_dialog.set_title('Enter text for "'+this.df.label+'"');text_dialog.field=this;text_dialog.show();}
|
||||
function SelectField(){}SelectField.prototype=new Field();SelectField.prototype.make_input=function(){var me=this;var opt=[];if(this.in_filter&&(!this.df.single_select)){this.input=$a(this.input_area,'select');this.input.multiple=true;this.input.style.height='4em';this.input.lab=$a(this.input_area,'div',{fontSize:'9px',color:'#999'});this.input.lab.innerHTML='(Use Ctrl+Click to select multiple or de-select)'}else{this.input=$a(this.input_area,'select');this.input.onchange=function(){if(me.validate)
|
||||
me.validate();me.set(sel_val(this));me.run_trigger();}
|
||||
if(this.df.options=='attach_files:'){this.file_attach=true;}}
|
||||
this.set_as_single=function(){var i=this.input;i.multiple=false;i.style.height=null;if(i.lab)$dh(i.lab)}
|
||||
this.refresh_options=function(options){if(options)
|
||||
me.df.options=options;if(this.file_attach)
|
||||
this.set_attach_options();me.options_list=me.df.options?me.df.options.split('\n'):[''];empty_select(this.input);if(me.in_filter&&me.options_list[0]!=''){me.options_list=add_lists([''],me.options_list);}
|
||||
add_sel_options(this.input,me.options_list);}
|
||||
this.onrefresh=function(){this.refresh_options();if(this.not_in_form){this.input.value='';return;}
|
||||
if(_f.get_value)
|
||||
var v=_f.get_value(this.doctype,this.docname,this.df.fieldname);else{if(this.options_list&&this.options_list.length)
|
||||
var v=this.options_list[0];else
|
||||
var v=null;}
|
||||
this.input.set_input(v);}
|
||||
this.input.set_input=function(v){if(!v){if(!me.input.multiple){if(me.docname){if(me.options_list&&me.options_list.length){me.set(me.options_list[0]);me.input.value=me.options_list[0];}else{me.input.value='';}}}}else{if(me.options_list){if(me.input.multiple){for(var i=0;i<me.input.options.length;i++){me.input.options[i].selected=0;if(me.input.options[i].value&&inList(typeof(v)=='string'?v.split(","):v,me.input.options[i].value))
|
||||
me.input.options[i].selected=1;}}else if(in_list(me.options_list,v)){me.input.value=v;}}}}
|
||||
this.get_value=function(){if(me.input.multiple){var l=[];for(var i=0;i<me.input.options.length;i++){if(me.input.options[i].selected)l[l.length]=me.input.options[i].value;}
|
||||
return l;}else{if(me.input.options){var val=sel_val(me.input);if(!val&&!me.input.selectedIndex)
|
||||
val=me.input.options[0].value;return val;}
|
||||
return me.input.value;}}
|
||||
this.set_attach_options=function(){if(!cur_frm)return;var fl=cur_frm.doc.file_list;if(fl){this.df.options='';var fl=fl.split('\n');for(var i in fl){this.df.options+='\n'+fl[i].split(',')[1];}}else{this.df.options=''}}
|
||||
this.refresh();}
|
||||
function TimeField(){}TimeField.prototype=new Field();TimeField.prototype.get_time=function(){return time_to_hhmm(sel_val(this.input_hr),sel_val(this.input_mn),sel_val(this.input_am));}
|
||||
TimeField.prototype.set_time=function(v){ret=time_to_ampm(v);this.input_hr.inp.value=ret[0];this.input_mn.inp.value=ret[1];this.input_am.inp.value=ret[2];}
|
||||
TimeField.prototype.set_style_mandatory=function(){}
|
||||
TimeField.prototype.set_as_error=function(){}
|
||||
TimeField.prototype.make_input=function(){var me=this;this.input=$a(this.input_area,'div','time_field');var t=make_table(this.input,1,3,'200px');var opt_hr=['1','2','3','4','5','6','7','8','9','10','11','12'];var opt_mn=['00','05','10','15','20','25','30','35','40','45','50','55'];var opt_am=['AM','PM'];this.input_hr=new SelectWidget($td(t,0,0),opt_hr,'50px');this.input_mn=new SelectWidget($td(t,0,1),opt_mn,'50px');this.input_am=new SelectWidget($td(t,0,2),opt_am,'50px');var onchange_fn=function(){me.set(me.get_time());me.run_trigger();}
|
||||
this.input_hr.inp.onchange=onchange_fn;this.input_mn.inp.onchange=onchange_fn;this.input_am.inp.onchange=onchange_fn;this.onrefresh=function(){var v=_f.get_value?_f.get_value(me.doctype,me.docname,me.df.fieldname):null;me.set_time(v);if(!v)
|
||||
me.set(me.get_time());}
|
||||
this.input.set_input=function(v){if(v==null)v='';me.set_time(v);}
|
||||
this.get_value=function(){return this.get_time();}
|
||||
this.refresh();}
|
||||
TimeField.prototype.set_disp=function(v){var t=time_to_ampm(v);var t=t[0]+':'+t[1]+' '+t[2];this.set_disp_html(t);}
|
||||
function makeinput_popup(me,iconsrc,iconsrc1,iconsrc2){var icon_style={cursor:'pointer',width:'16px',verticalAlign:'middle',marginBottom:'-3px'};me.input=$a(me.input_area,'div');if(!me.not_in_form)
|
||||
$y(me.input,{width:'80%'});me.input.set_width=function(w){$y(me.input,{width:(w-2)+'px'});}
|
||||
var tab=$a(me.input,'table');me.tab=tab;$y(tab,{width:'100%',borderCollapse:'collapse',tableLayout:'fixed'});var c0=tab.insertRow(0).insertCell(0);var c1=tab.rows[0].insertCell(1);$y(c1,{width:'20px'});me.txt=$a($a($a(c0,'div','',{paddingRight:'8px'}),'div'),'input','',{width:'100%'});me.btn=$a(c1,'i',iconsrc,icon_style)
|
||||
if(iconsrc1)
|
||||
me.btn.setAttribute('title','Search');else
|
||||
me.btn.setAttribute('title','Select Date');if(iconsrc1){var c2=tab.rows[0].insertCell(2);$y(c2,{width:'20px'});me.btn1=$a(c2,'i',iconsrc1,icon_style)
|
||||
me.btn1.setAttribute('title','Open Link');}
|
||||
if(iconsrc2){var c3=tab.rows[0].insertCell(3);$y(c3,{width:'20px'});me.btn2=$a(c3,'i',iconsrc2,icon_style)
|
||||
me.btn2.setAttribute('title','Create New');$dh(me.btn2);}
|
||||
if(me.df.colour)
|
||||
me.txt.style.background='#'+me.df.colour.split(':')[1];me.txt.name=me.df.fieldname;me.setdisabled=function(tf){me.txt.disabled=tf;}}
|
||||
var tmpid=0;_f.ButtonField=function(){};_f.ButtonField.prototype=new Field();_f.ButtonField.prototype.with_label=0;_f.ButtonField.prototype.init=function(){this.prev_button=null;if(!this.frm)return;if(cur_frm&&cur_frm.fields[cur_frm.fields.length-1]&&cur_frm.fields[cur_frm.fields.length-1].df.fieldtype=='Button'){this.make_body=function(){this.prev_button=cur_frm.fields[cur_frm.fields.length-1];if(!this.prev_button.prev_button){this.prev_button.button_area=$a(this.prev_button.input_area,'span');}
|
||||
this.wrapper=this.prev_button.wrapper;this.input_area=this.prev_button.input_area;this.disp_area=this.prev_button.disp_area;this.button_area=$a(this.prev_button.input_area,'span');}}}
|
||||
_f.ButtonField.prototype.make_input=function(){var me=this;if(!this.prev_button){$y(this.input_area,{marginTop:'4px',marginBottom:'4px'});}
|
||||
if(!this.button_area)
|
||||
this.button_area=$a(this.input_area,'span','',{marginRight:'4px'});this.input=$btn(this.button_area,me.df.label,null,{fontWeight:'bold'},null,1)
|
||||
this.input.onclick=function(){if(me.not_in_form)return;this.disabled='disabled';if(cur_frm.cscript[me.df.fieldname]&&(!me.in_filter)){cur_frm.runclientscript(me.df.fieldname,me.doctype,me.docname);this.disabled=false;}else{cur_frm.runscript(me.df.options,me);this.disabled=false;}}}
|
||||
_f.ButtonField.prototype.hide=function(){$dh(this.button_area);};_f.ButtonField.prototype.show=function(){$ds(this.button_area);};_f.ButtonField.prototype.set=function(v){};_f.ButtonField.prototype.set_disp=function(val){}
|
||||
function make_field(docfield,doctype,parent,frm,in_grid,hide_label){switch(docfield.fieldtype.toLowerCase()){case'data':var f=new DataField();break;case'password':var f=new DataField();break;case'int':var f=new IntField();break;case'float':var f=new FloatField();break;case'currency':var f=new CurrencyField();break;case'read only':var f=new ReadOnlyField();break;case'link':var f=new LinkField();break;case'date':var f=new DateField();break;case'time':var f=new TimeField();break;case'html':var f=new HTMLField();break;case'check':var f=new CheckField();break;case'text':var f=new TextField();break;case'small text':var f=new TextField();break;case'select':var f=new SelectField();break;case'button':var f=new _f.ButtonField();break;case'code':var f=new _f.CodeField();break;case'text editor':var f=new _f.CodeField();break;case'table':var f=new _f.TableField();break;case'section break':var f=new _f.SectionBreak();break;case'column break':var f=new _f.ColumnBreak();break;case'image':var f=new _f.ImageField();break;}
|
||||
f.parent=parent;f.doctype=doctype;f.df=docfield;f.perm=frm?frm.perm:[[1,1,1]];if(_f)
|
||||
f.col_break_width=_f.cur_col_break_width;if(in_grid){f.in_grid=true;f.with_label=0;}
|
||||
if(hide_label){f.with_label=0;}
|
||||
if(frm){f.frm=frm;if(parent)
|
||||
f.layout_cell=parent.parentNode;}
|
||||
if(f.init)f.init();f.make_body();return f;}
|
95
public/js/listing.js
Normal file
@ -0,0 +1,95 @@
|
||||
|
||||
/*
|
||||
* lib/js/legacy/widgets/listing.js
|
||||
*/
|
||||
list_opts={cell_style:{padding:'3px 2px'},alt_cell_style:{},head_style:{height:'20px',overflow:'hidden',verticalAlign:'middle',fontWeight:'bold',padding:'1px',fontSize:'13px'},head_main_style:{padding:'0px'},hide_export:1,hide_print:1,hide_refresh:0,hide_rec_label:0,show_calc:1,show_empty_tab:0,no_border:1,append_records:1,table_width:null};function Listing(head_text,no_index,no_loading){this.start=0;this.page_len=20;this.filters_per_line=7;this.cell_idx=0;this.head_text=head_text?head_text:'Result';this.keyword='records';this.no_index=no_index;this.underline=1;this.no_rec_message='No Result';this.show_cell=null;this.show_result=null;this.colnames=null;this.colwidths=null;this.coltypes=null;this.coloptions=null;this.filters={};this.sort_list={};this.sort_order_dict={};this.sort_heads={};this.is_std_query=false;this.server_call=null;this.no_loading=no_loading;this.opts=copy_dict(list_opts);}
|
||||
Listing.prototype.make=function(parent){var me=this;this.wrapper=parent;this.filter_wrapper=$a(parent,'div','srs_filter_wrapper');this.filter_area=$a(this.filter_wrapper,'div','srs_filter_area');$dh(this.filter_wrapper);this.btn_area=$a(parent,'div','',{margin:'8px 0px'});this.body_area=$a(parent,'div','srs_body_area');if(!this.opts.hide_rec_label)
|
||||
this.rec_label=$a(this.body_area,'div','',{margin:'4px 0px',color:'#888'});this.results=$a($a(this.body_area,'div','srs_results_area'),'div');this.fetching_area=$a(this.body_area,'div','',{height:'120px',background:'url("images/lib/ui/square_loading.gif") center no-repeat',display:'none'});this.show_no_records=$a(this.body_area,'div','',{margin:'200px 0px',textAlign:'center',fontSize:'14px',color:'#888',display:'none'});this.show_no_records.innerHTML='No Result';if(this.opts.show_empty_tab)
|
||||
this.make_result_tab();this.bottom_div=$a(this.body_area,'div','',{paddingTop:'8px'});this.make_toolbar();}
|
||||
Listing.prototype.make_toolbar=function(){var me=this;this.buttons={};var make_btn=function(label,icon,onclick,bold){var btn=$btn(me.btn_area,label,onclick,{marginRight:'4px'});if(bold)$y(btn,{fontWeight:'bold'});me.buttons[label]=btn;}
|
||||
if(!this.opts.hide_refresh){make_btn('Refresh','ui-icon-refresh',function(btn){me.start=0;me.run();},1);}
|
||||
if(this.opts.show_new){make_btn('New ','ui-icon-document',function(){new_doc(me.dt);},1);}
|
||||
if(this.opts.show_report){make_btn('Report Builder','ui-icon-clipboard',function(){loadreport(me.dt,null,null,null,1);},0);}
|
||||
if(!this.opts.hide_export){make_btn('Export','ui-icon-circle-arrow-e',function(){me.do_export();});}
|
||||
if(!this.opts.hide_print){make_btn('Print','ui-icon-print',function(){me.do_print();});}
|
||||
if(this.opts.show_calc){make_btn('Calc','ui-icon-calculator',function(){me.do_calc();});$dh(me.buttons['Calc'])}
|
||||
this.loading_img=$a(this.btn_area,'img','',{display:'none',marginBottom:'-2px'});this.loading_img.src='images/lib/ui/button-load.gif';if(!keys(this.buttons).length)
|
||||
$dh(this.btn_area);}
|
||||
Listing.prototype.do_print=function(){this.build_query();if(!this.query){alert('No Query!');return;}
|
||||
args={query:this.query,title:this.head_text,colnames:this.colnames,colwidths:this.colwidths,coltypes:this.coltypes,has_index:(this.no_index?0:1),has_headings:1,check_limit:1,is_simple:1}
|
||||
wn.require('js/print_query.js');_p.print_query=new _p.PrintQuery();_p.print_query.show_dialog(args);}
|
||||
Listing.prototype.do_calc=function(){show_calc(this.result_tab,this.colnames,this.coltypes,0)}
|
||||
Listing.prototype.add_filter=function(label,ftype,options,tname,fname,cond){if(!this.filter_area){alert('[Listing] make() must be called before add_filter');}
|
||||
var me=this;if(!this.filter_set){var h=$a(this.filter_area,'div','',{fontSize:'14px',fontWeight:'bold',marginBottom:'4px'});h.innerHTML='Filter your search';this.filter_area.div=$a(this.filter_area,'div');this.perm=[[1,1],]
|
||||
this.filters={};}
|
||||
$ds(this.filter_wrapper);if((!this.inp_tab)||(this.cell_idx==this.filters_per_line)){this.inp_tab=$a(this.filter_area.div,'table','',{width:'100%',tableLayout:'fixed'});this.inp_tab.insertRow(0);for(var i=0;i<this.filters_per_line;i++){this.inp_tab.rows[0].insertCell(i);}
|
||||
this.cell_idx=0;}
|
||||
var c=this.inp_tab.rows[0].cells[this.cell_idx];this.cell_idx++;$y(c,{width:cint(100/this.filters_per_line)+'%',textAlign:'left',verticalAlign:'top'});var d1=$a(c,'div','',{fontSize:'11px',marginBottom:'2px'});d1.innerHTML=label;if(ftype=='Link')d1.innerHTML+=' <img src="images/lib/icons/link.png" style="margin-bottom:-5px" title="Link">';var d2=$a(c,'div');if(in_list(['Text','Small Text','Code','Text Editor','Read Only'],ftype))
|
||||
ftype='Data';if(ftype=='Select'&&!in_list(options.split('\n'),''))options='\n'+options
|
||||
var inp=make_field({fieldtype:ftype,'label':label,'options':options,no_buttons:1},'',d2,this,0,1);inp.not_in_form=1;inp.report=this;inp.df.single_select=1;inp.parent_cell=c;inp.parent_tab=this.input_tab;$y(inp.wrapper,{width:'95%'});inp.refresh();inp.tn=tname;inp.fn=fname;inp.condition=ftype=='Data'?'like':cond;var me=this;inp.onchange=function(){me.start=0;}
|
||||
this.filters[label]=inp;this.filter_set=1;}
|
||||
Listing.prototype.remove_filter=function(label){var inp=this.filters[label];inp.parent_tab.rows[0].deleteCell(inp.parent_cell.cellIndex);delete this.filters[label];}
|
||||
Listing.prototype.remove_all_filters=function(){for(var k in this.filters)this.remove_filter(k);$dh(this.filter_wrapper);}
|
||||
Listing.prototype.add_sort=function(ci,fname){this.sort_list[ci]=fname;}
|
||||
Listing.prototype.has_data=function(){return this.n_records;}
|
||||
Listing.prototype.set_default_sort=function(fname,sort_order){this.sort_order=sort_order;this.sort_order_dict[fname]=sort_order;this.sort_by=fname;if(this.sort_heads[fname])
|
||||
this.sort_heads[fname].set_sorting_as(sort_order);}
|
||||
Listing.prototype.set_sort=function(cell,ci,fname){var me=this;$y(cell.sort_cell,{width:'18px'});cell.sort_img=$a(cell.sort_cell,'img');cell.fname=fname;$dh(cell.sort_img);cell.set_sort_img=function(order){var t='images/icons/sort_desc.gif';if(order=='ASC'){t='images/icons/sort_asc.gif';}
|
||||
this.sort_img.src=t;}
|
||||
cell.set_sorting_as=function(order){me.sort_order=order;me.sort_by=this.fname
|
||||
me.sort_order_dict[this.fname]=order;this.set_sort_img(order)
|
||||
if(me.cur_sort){$y(me.cur_sort,{backgroundColor:"#FFF"});$dh(me.cur_sort.sort_img);}
|
||||
me.cur_sort=this;$y(this,{backgroundColor:"#DDF"});$di(this.sort_img);}
|
||||
$y(cell.label_cell,{color:'#44A',cursor:'pointer'});cell.set_sort_img(me.sort_order_dict[fname]?me.sort_order_dict[fname]:'ASC');cell.onmouseover=function(){$di(this.sort_img);}
|
||||
cell.onmouseout=function(){if(this!=me.cur_sort)
|
||||
$dh(this.sort_img);}
|
||||
cell.onclick=function(){this.set_sorting_as((me.sort_order_dict[fname]=='ASC')?'DESC':'ASC');me.run();}
|
||||
this.sort_heads[fname]=cell;}
|
||||
Listing.prototype.do_export=function(){this.build_query();var me=this;me.cn=[];if(this.no_index)
|
||||
me.cn=this.colnames;else{for(var i=1;i<this.colnames.length;i++)
|
||||
me.cn.push(this.colnames[i]);}
|
||||
var q=export_query(this.query,function(query){export_csv(query,me.head_text,null,1,null,me.cn);});}
|
||||
Listing.prototype.build_query=function(){if(this.get_query)this.get_query(this);if(!this.query){alert('No Query!');return;}
|
||||
if(!this.prefix)this.prefix='tab';var cond=[];for(var i in this.filters){var f=this.filters[i];var val=f.get_value();var c=f.condition;if(!c)c='=';if(val&&c.toLowerCase()=='like')val+='%';if(f.tn&&val&&!in_list(['All','Select...',''],val))
|
||||
cond.push(repl(' AND `%(prefix)s%(dt)s`.%(fn)s %(condition)s "%(val)s"',{prefix:this.prefix,dt:f.tn,fn:f.fn,condition:c,val:val}));}
|
||||
if(cond){this.query+=NEWLINE+cond.join(NEWLINE)
|
||||
if(this.query_max)
|
||||
this.query_max+=NEWLINE+cond.join(NEWLINE)}
|
||||
if(this.group_by)
|
||||
this.query+=' '+this.group_by+' ';if(this.sort_by&&this.sort_order){this.query+=NEWLINE+' ORDER BY `'+this.sort_by+'` '+this.sort_order;}
|
||||
if(this.show_query)msgprint(this.query);}
|
||||
Listing.prototype.set_rec_label=function(total,cur_page_len){if(this.opts.hide_rec_label)
|
||||
return;else if(total==-1)
|
||||
this.rec_label.innerHTML='Fetching...'
|
||||
else if(total>0)
|
||||
this.rec_label.innerHTML=repl('Total %(total)s %(keyword)s. Showing %(start)s to %(end)s',{total:total,start:cint(this.start)+1,end:cint(this.start)+cint(cur_page_len),keyword:this.keyword});else if(total==null)
|
||||
this.rec_label.innerHTML=''
|
||||
else if(total==0)
|
||||
this.rec_label.innerHTML=this.no_rec_message;}
|
||||
Listing.prototype.run=function(run_callback){this.build_query();var q=this.query;var me=this;if(this.max_len&&this.start>=this.max_len)this.start-=this.page_len;q+=' LIMIT '+this.start+','+this.page_len;var call_back=function(r,rt){$dh(me.loading_img);me.max_len=r.n_values;if(r.values&&r.values.length){me.n_records=r.values.length;var nc=r.values[0].length;if(me.colwidths)nc=me.colwidths.length-(me.no_index?0:1);if(me.opts.append_records&&me.start!=0){me.append_rows(r.values.length);}else{me.clear_tab();if(!me.show_empty_tab){me.remove_result_tab();me.make_result_tab(r.values.length);}}
|
||||
me.refresh(r.values.length,nc,r.values,r.n_values);me.total_records=r.n_values;me.set_rec_label(r.n_values,r.values.length);}else{me.n_records=0;me.set_rec_label(0);me.clear_tab();if(!me.opts.append_records){if(me.show_empty_tab){me.clear_tab();}else{me.remove_result_tab();me.make_result_tab(0);if(me.opts.show_no_records_label){$ds(me.show_no_records);}}}}
|
||||
$ds(me.results);if(run_callback)run_callback();if(me.onrun)me.onrun();}
|
||||
$dh(me.show_no_records);this.set_rec_label(-1);$di(this.loading_img);if(this.server_call){this.server_call(this,call_back);}else{args={query_max:(this.query_max?this.query_max:'')}
|
||||
if(this.is_std_query)args.query=q;else args.simple_query=q;if(this.opts.formatted)args.formatted=1;$c('webnotes.widgets.query_builder.runquery',args,call_back,null,this.no_loading);}}
|
||||
Listing.prototype.remove_result_tab=function(){if(!this.result_tab)return;this.result_tab.parentNode.removeChild(this.result_tab);delete this.result_tab;}
|
||||
Listing.prototype.reset_tab=function(){this.remove_result_tab();this.make_result_tab();}
|
||||
Listing.prototype.make_result_tab=function(nr){if(this.result_tab)return;if(!this.colwidths)alert("Listing: Must specify column widths");var has_headrow=this.colnames?1:0;if(nr==null)nr=this.page_len;nr+=has_headrow;var nc=this.colwidths.length;var t=make_table(this.results,nr,nc,(this.opts.table_width?this.opts.table_width:'100%'),this.colwidths,{padding:'0px'});t.className='srs_result_tab';this.result_tab=t;$y(t,{borderCollapse:'collapse'});if(this.opts.table_width){$y(this.results,{overflowX:'auto'});$y(t,{tableLayout:'fixed'});}
|
||||
if(has_headrow){this.make_headings(t,nr,nc);if(this.sort_by&&this.sort_heads[this.sort_by]){this.sort_heads[this.sort_by].set_sorting_as(this.sort_order);}}
|
||||
this.set_table_style();if(this.opts.no_border==1){$y(t,{border:'0px'});}
|
||||
this.result_tab=t;}
|
||||
Listing.prototype.set_table_style=function(){var t=this.result_tab;for(var ri=(this.colnames?1:0);ri<t.rows.length;ri++){for(var ci=0;ci<t.rows[ri].cells.length;ci++){if(this.opts.cell_style)$y($td(t,ri,ci),this.opts.cell_style);if(this.opts.alt_cell_style&&(ri%2))$y($td(t,ri,ci),this.opts.alt_cell_style);if(this.opts.show_empty_tab&&!$td(t,ri,ci).innerHTML)$td(t,ri,ci).innerHTML=' ';}}}
|
||||
Listing.prototype.append_rows=function(nr){for(var i=0;i<nr;i++){append_row(this.result_tab);}
|
||||
this.set_table_style();}
|
||||
Listing.prototype.clear_tab=function(){$dh(this.results);if(this.result_tab){var nr=this.result_tab.rows.length;var nc=this.result_tab.rows[0].cells.length;for(var ri=(this.colnames?1:0);ri<nr;ri++)
|
||||
for(var ci=0;ci<nc;ci++)
|
||||
$td(this.result_tab,ri,ci).innerHTML=(this.opts.show_empty_tab?' ':'');}}
|
||||
Listing.prototype.clear=function(){this.rec_label.innerHTML='';this.clear_tab();}
|
||||
Listing.prototype.refresh_calc=function(){if(!this.opts.show_calc)return;if(has_common(this.coltypes,['Currency','Int','Float'])){$di(this.buttons['Calc']);}else{$dh(this.buttons['Calc']);}}
|
||||
Listing.prototype.refresh=function(nr,nc,d,n_values){this.refresh_more_button(nr,n_values);this.refresh_calc();if(this.show_result)
|
||||
this.show_result();else{if(nr){var start=this.result_tab.rows.length-nr;for(var ri=start;ri<start+nr;ri++){var c0=$td(this.result_tab,ri,0);if(!this.no_index){c0.innerHTML=cint(this.start)+cint(ri-start)+1;}
|
||||
for(var ci=0;ci<nc;ci++){var c=$td(this.result_tab,ri,ci+(this.no_index?0:1));if(c){c.innerHTML='';if(this.show_cell)this.show_cell(c,ri-start,ci,d);else this.std_cell(c,ri-start,ci,d);}}}}}}
|
||||
Listing.prototype.refresh_more_button=function(nr,n_values){var me=this;if(this.more_btn){$dh(this.more_btn);}
|
||||
if((this.start+nr)==this.max_len||(!this.max_len&&nr<this.page_len)){}else if(nr){if(!this.more_btn){$y(this.bottom_div,{margin:'8px 0px 16px 0px',textAlign:'center'});this.more_btn=$btn(this.bottom_div,'Show more results...',function(){me.start=me.start+me.page_len;me.more_btn.set_working();me.run(function(){me.more_btn.done_working();});},{fontSize:'14px'},0,1);$y(this.more_btn.loading_img,{marginBottom:'0px'});}
|
||||
$di(this.more_btn);}}
|
||||
Listing.prototype.make_headings=function(t,nr,nc){for(var ci=0;ci<nc;ci++){var tmp=make_table($td(t,0,ci),1,2,'100%',['','0px'],this.opts.head_style);$y(tmp,{tableLayout:'fixed',borderCollapse:'collapse'});$y($td(t,0,ci),this.opts.head_main_style);$td(t,0,ci).sort_cell=$td(tmp,0,1);$td(t,0,ci).label_cell=$td(tmp,0,0);$td(tmp,0,1).style.padding='0px';$td(tmp,0,0).innerHTML=this.colnames[ci]?this.colnames[ci]:' ';if(this.sort_list[ci])this.set_sort($td(t,0,ci),ci,this.sort_list[ci]);var div=$a($td(t,0,ci),'div');$td(t,0,ci).style.borderBottom='1px solid #CCC';if(this.coltypes&&this.coltypes[ci]&&in_list(['Currency','Float','Int'],this.coltypes[ci]))$y($td(t,0,ci).label_cell,{textAlign:'right'})}}
|
||||
Listing.prototype.std_cell=function(cell,ri,ci,d){var has_headrow=this.colnames?1:0;cell.div=$a(cell,'div');$s(cell.div,d[ri][ci],this.coltypes?this.coltypes[ci+(this.no_index?0:1)]:null,this.coloptions?this.coloptions[ci+(this.no_index?0:1)]:null);}
|
41
public/js/print_query.js
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
/*
|
||||
* lib/js/legacy/widgets/print_query.js
|
||||
*/
|
||||
_p.PrintQuery=function(){this.args={};}
|
||||
_p.PrintQuery.prototype.show_dialog=function(args){this.args=args;var me=this;if(!this.dialog){var d=new Dialog(400,300,"Print");d.make_body([['Data','Max rows','Blank to print all rows'],['Data','Rows per page'],['Button','Go'],]);d.widgets['Go'].onclick=function(){d.hide();me.render(cint(d.widgets['Max rows'].value),cint(d.widgets['Rows per page'].value))}
|
||||
d.onshow=function(){this.widgets['Rows per page'].value='35';this.widgets['Max rows'].value='500';}
|
||||
this.dialog=d;}
|
||||
this.dialog.show();}
|
||||
_p.PrintQuery.prototype.render=function(max_rows,page_len){var me=this;var args=me.args;if(cint(max_rows)!=0)args.query+=' LIMIT 0,'+cint(max_rows);if(!args.query)return;var callback=function(r,rt){if(!r.values){return;}
|
||||
if(!page_len)page_len=r.values.length;if(r.colnames&&r.colnames.length)
|
||||
args.colnames=args.has_index?add_lists(['Sr'],r.colnames):r.colnames;if(r.colwidths&&r.colwidths.length)
|
||||
args.colwidths=args.has_index?add_lists(['25px'],r.colwidths):r.colwidths;if(r.coltypes)
|
||||
args.coltypes=args.has_index?add_lists(['Data'],r.coltypes):r.coltypes;if(args.coltypes){for(var i in args.coltypes)
|
||||
if(args.coltypes[i]=='Link')args.coltypes[i]='Data';}
|
||||
if(args.colwidths){var tw=0;for(var i=0;i<args.colwidths.length;i++)tw+=cint(args.colwidths[i]?args.colwidths[i]:100);for(var i=0;i<args.colwidths.length;i++)args.colwidths[i]=cint(cint(args.colwidths[i]?args.colwidths[i]:100)/tw*100)+'%';}
|
||||
var has_heading=args.colnames?1:0;if(!args.has_headings)has_heading=0;var tl=[]
|
||||
for(var st=0;st<r.values.length;st=st+page_len){tl.push(me.build_table(r,st,page_len,has_heading,args.rb))}
|
||||
var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
|
||||
+'<html><head>'
|
||||
+'<title>'+args.title+'</title>'
|
||||
+'<style>'+_p.def_print_style_body+_p.def_print_style_other+'</style>'
|
||||
+'</head><body>'
|
||||
+(r.header_html?r.header_html:'')
|
||||
+tl.join('\n<div style="page-break-after: always;"></div>\n')
|
||||
+(r.footer_html?r.footer_html:'')
|
||||
+'</body></html>';_p.preview(html);}
|
||||
var out_args=copy_dict(args);if(args.is_simple){out_args.simple_query=args.query;delete out_args.query;}
|
||||
if(args.filter_values)
|
||||
out_args.filter_values=args.filter_values;$c('webnotes.widgets.query_builder.runquery',out_args,callback);}
|
||||
_p.PrintQuery.prototype.build_table=function(r,start,page_len,has_heading,rb){var div=document.createElement('div');if(!r.page_template){var head=$a(div,'div',null,{fontSize:'20px',fontWeight:'bold',margin:'16px 0px',borderBottom:'1px solid #CCC',paddingBottom:'8px'});head.innerHTML=args.title;}
|
||||
var m=start+page_len;if(m>r.values.length)m=r.values.length
|
||||
var t=make_table(div,m+has_heading-start,r.values[0].length+args.has_index,'100%',null);t.className='simpletable';if(args.colwidths)
|
||||
$y(t,{tableLayout:'fixed'});if(has_heading){for(var i=0;i<args.colnames.length;i++){$td(t,0,i).innerHTML=args.colnames[i].bold();if(args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}}}
|
||||
for(var ri=start;ri<m;ri++){if(args.has_index)
|
||||
$td(t,ri+has_heading-start,0).innerHTML=ri+1;for(var ci=0;ci<r.values[0].length;ci++){if(ri-start==0&&args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}
|
||||
var c=$td(t,ri+has_heading-start,ci+args.has_index)
|
||||
c.div=$a(c,'div','',{whiteSpace:'normal'});$s(c.div,r.values[ri][ci],args.coltypes?args.coltypes[ci+args.has_index]:null);}}
|
||||
if(r.style){for(var i=0;i<r.style.length;i++){$yt(t,r.style[i][0],r.style[i][1],r.style[i][2]);}}
|
||||
if(rb&&rb.aftertableprint){rb.aftertableprint(t);}
|
||||
if(r.page_template)return repl(r.page_template,{table:div.innerHTML});else return div.innerHTML;}
|
237
public/js/report-legacy.js
Normal file
@ -0,0 +1,237 @@
|
||||
|
||||
/*
|
||||
* lib/js/legacy/widgets/report_builder/report_builder.js
|
||||
*/
|
||||
_r.ReportContainer=function(){if(user=='Guest'){msgprint("Not Allowed");return;}
|
||||
var page=wn.container.add_page("Report Builder");this.wrapper=$a(page,'div','layout-wrapper',{padding:'0px'});this.appframe=new wn.ui.AppFrame(this.wrapper);this.appframe.$titlebar.append('<span class="report-title">');this.rb_area=$a(this.wrapper,'div','',{padding:'15px'});var me=this;this.rb_dict={};var run_fn=function(){if(me.cur_rb){me.cur_rb.dt.start_rec=1;me.cur_rb.dt.run();}}
|
||||
var runbtn=this.appframe.add_button('Run',run_fn,'icon-refresh');this.appframe.add_button('Export',function(){me.cur_rb&&me.cur_rb.dt.do_export();},'icon-download-alt');this.appframe.add_button('Print',function(){me.cur_rb&&me.cur_rb.dt.do_print();},'icon-print');this.appframe.add_button('Calc',function(){me.cur_rb&&me.cur_rb.dt.do_calc();},'icon-plus');if(has_common(['Administrator','System Manager'],user_roles)){var savebtn=this.appframe.add_button('Save',function(){if(me.cur_rb)me.cur_rb.save_criteria();});var fn=function(){if(me.cur_rb){if(!me.cur_rb.current_loaded){msgprint("error:You must save the report before you can set Advanced features");return;}
|
||||
loaddoc('Search Criteria',me.cur_rb.sc_dict[me.cur_rb.current_loaded]);}};var advancedbtn=this.appframe.add_button('Advanced Settings',fn,'icon-cog');}
|
||||
this.set_dt=function(dt,onload){my_onload=function(f){if(!f.forbidden){me.cur_rb=f;me.cur_rb.mytabs.items['Result'].expand();if(onload)onload(f);}}
|
||||
if(me.cur_rb)
|
||||
me.cur_rb.hide();if(me.rb_dict[dt]){me.rb_dict[dt].show(my_onload);}else{me.rb_dict[dt]=new _r.ReportBuilder(me.rb_area,dt,my_onload);}}}
|
||||
_r.ReportBuilder=function(parent,doctype,onload){this.menuitems={};this.has_primary_filters=false;this.doctype=doctype;this.forbidden=0;this.filter_fields=[];this.filter_fields_dict={};var me=this;this.fn_list=['beforetableprint','beforerowprint','afterrowprint','aftertableprint','customize_filters','get_query'];this.wrapper=$a(parent,'div','finder_wrapper');this.make_tabs();this.current_loaded=null;this.setup_doctype(onload);this.hide=function(){$dh(me.wrapper);}
|
||||
this.show=function(my_onload){$ds(me.wrapper);this.set_main_title('Report: '+get_doctype_label(me.doctype));if(my_onload)my_onload(me);}}
|
||||
_r.ReportBuilder.prototype.make_tabs=function(){this.tab_wrapper=$a(this.wrapper,'div','finder_tab_area');this.mytabs=new TabbedPage(this.tab_wrapper);this.mytabs.add_item('Result',null,null,1);this.mytabs.add_item('More Filters',null,null,1);this.mytabs.add_item('Select Columns',null,null,1);this.mytabs.tabs=this.mytabs.items;}
|
||||
_r.ReportBuilder.prototype.make_body=function(){this.set_main_title('Report: '+get_doctype_label(this.doctype));var me=this;this.make_save_criteria();this.column_picker=new _r.ReportColumnPicker(this);this.report_filters=new _r.ReportFilters(this);}
|
||||
_r.ReportBuilder.prototype.make_save_criteria=function(){var me=this;this.sc_list=[];this.sc_dict={};for(var n in locals['Search Criteria']){var d=locals['Search Criteria'][n];if(d.doc_type==this.doctype){this.sc_list[this.sc_list.length]=d.criteria_name;this.sc_dict[d.criteria_name]=n;}}}
|
||||
_r.ReportBuilder.prototype.save_criteria=function(save_as){var overwrite=0;if(this.current_loaded&&(!save_as)){var overwrite=confirm('Do you want to overwrite the saved criteria "'+this.current_loaded+'"');if(overwrite){var doc=locals['Search Criteria'][this.sc_dict[this.current_loaded]];var criteria_name=this.current_loaded;}}
|
||||
if(!overwrite){var criteria_name=prompt('Select a name for the criteria:','');if(!criteria_name)
|
||||
return;var dn=createLocal('Search Criteria');var doc=locals['Search Criteria'][dn];doc.criteria_name=criteria_name;doc.doc_type=this.doctype;}
|
||||
var cl=[];var fl={};var t=this.column_picker.get_selected();for(var i=0;i<t.length;i++)
|
||||
cl.push(t[i].parent+'\1'+t[i].label);for(var i=0;i<this.filter_fields.length;i++){var t=this.filter_fields[i];var v=t.get_value?t.get_value():'';if(v)fl[t.df.parent+'\1'+t.df.label+(t.bound?('\1'+t.bound):'')]=v;}
|
||||
doc.columns=cl.join(',');doc.filters=JSON.stringify(fl);doc.sort_by=sel_val(this.dt.sort_sel);doc.sort_order=this.dt.sort_order;doc.page_len=this.dt.page_len;if(this.parent_dt)
|
||||
doc.parent_doc_type=this.parent_dt
|
||||
var me=this;var fn=function(r){me.sc_dict[criteria_name]=r.main_doc_name;me.set_criteria_sel(criteria_name);}
|
||||
save_doclist(doc.doctype,doc.name,'Save',fn);}
|
||||
_r.ReportBuilder.prototype.hide_all_filters=function(){for(var i=0;i<this.filter_fields.length;i++){this.filter_fields[i].df.filter_hide=1;}}
|
||||
_r.ReportBuilder.prototype.run=function(){this.dt.run();}
|
||||
_r.ReportBuilder.prototype.clear_criteria=function(){this.column_picker.clear();this.column_picker.set_defaults();for(var i=0;i<this.filter_fields.length;i++){this.filter_fields[i].df.filter_hide=0;this.filter_fields[i].df.ignore=0;if(this.filter_fields[i].is_custom){this.filter_fields[i].df.filter_hide=1;this.filter_fields[i].df.ignore=1;}
|
||||
this.filter_fields[i].set_input(null);}
|
||||
this.set_sort_options();this.set_main_title('Report: '+get_doctype_label(this.doctype));this.current_loaded=null;this.customized_filters=null;this.sc=null;this.has_index=1;this.has_headings=1;for(var i in this.fn_list)this[this.fn_list[i]]=null;}
|
||||
_r.ReportBuilder.prototype.set_main_title=function(t,t1){var title=t+(t1?t1:'');_r.rb_con.appframe.$titlebar.find('.report-title').html(title);set_title(title);}
|
||||
_r.ReportBuilder.prototype.select_column=function(dt,label,value){if(value==null)value=1;this.column_picker.set(dt,label,value);}
|
||||
_r.ReportBuilder.prototype.set_filter=function(dt,label,value){if(this.filter_fields_dict[dt+'\1'+label])
|
||||
this.filter_fields_dict[dt+'\1'+label].set_input(value);}
|
||||
_r.ReportBuilder.prototype.load_criteria=function(criteria_name){this.clear_criteria();if(!this.sc_dict[criteria_name]){alert(criteria_name+' could not be loaded. Please Refresh and try again');}
|
||||
this.sc=locals['Search Criteria'][this.sc_dict[criteria_name]];var report=this;if(this.sc&&this.sc.report_script)eval(this.sc.report_script);this.large_report=0;if(report.customize_filters){try{report.customize_filters(this);}catch(err){errprint('Error in "customize_filters":\n'+err);}}
|
||||
this.report_filters.refresh();this.column_picker.clear();var cl=this.sc.columns?this.sc.columns.split(','):[];for(var c=0;c<cl.length;c++){var key=cl[c].split('\1');this.select_column(key[0],key[1],1);}
|
||||
eval('var fl='+this.sc.filters);for(var n in fl){if(fl[n]){var key=n.split('\1');if(key[1]=='docstatus'){}
|
||||
this.set_filter(key[0],key[1],fl[n]);}}
|
||||
this.set_criteria_sel(criteria_name);this.set_filters_from_route();}
|
||||
_r.ReportBuilder.prototype.set_criteria_sel=function(criteria_name){var sc=locals['Search Criteria'][this.sc_dict[criteria_name]];if(sc&&sc.add_col)
|
||||
var acl=sc.add_col.split('\n');else
|
||||
var acl=[];var new_sl=[];for(var i=0;i<acl.length;i++){var tmp=acl[i].split(' AS ');if(tmp[1]){var t=eval(tmp[1]);new_sl[new_sl.length]=[t,"`"+t+"`"];}}
|
||||
this.set_sort_options(new_sl);if(sc&&sc.sort_by){this.dt.sort_sel.value=sc.sort_by;}
|
||||
if(sc&&sc.sort_order){sc.sort_order=='ASC'?this.dt.set_asc():this.dt.set_desc();}
|
||||
if(sc&&sc.page_len){this.dt.page_len_sel.inp.value=sc.page_len;}
|
||||
this.current_loaded=criteria_name;this.set_main_title(criteria_name,sc.description);}
|
||||
_r.ReportBuilder.prototype.setup_filters_and_cols=function(){function can_dt_be_submitted(dt){if(locals.DocType&&locals.DocType[dt]&&locals.DocType[dt].allow_trash)return 1;var plist=getchildren('DocPerm',dt,'permissions','DocType');for(var pidx in plist){if(plist[pidx].submit)return 1;}
|
||||
return 0;}
|
||||
var me=this;var dt=me.parent_dt?me.parent_dt:me.doctype;var fl=[{'fieldtype':'Data','label':'ID','fieldname':'name','in_filter':1,'parent':dt},{'fieldtype':'Data','label':'Owner','fieldname':'owner','in_filter':1,'parent':dt},{'fieldtype':'Date','label':'Created on','fieldname':'creation','in_filter':0,'parent':dt},{'fieldtype':'Date','label':'Last modified on','fieldname':'modified','in_filter':0,'parent':dt},];if(can_dt_be_submitted(dt)){fl[fl.length]={'fieldtype':'Check','label':'Saved','fieldname':'docstatus','search_index':1,'in_filter':1,'def_filter':1,'parent':dt};fl[fl.length]={'fieldtype':'Check','label':'Submitted','fieldname':'docstatus','search_index':1,'in_filter':1,'def_filter':1,'parent':dt};fl[fl.length]={'fieldtype':'Check','label':'Cancelled','fieldname':'docstatus','search_index':1,'in_filter':1,'parent':dt};}
|
||||
me.make_datatable();me.orig_sort_list=[];if(me.parent_dt){me.setup_dt_filters_and_cols(fl,me.parent_dt);var fl=[];}
|
||||
me.setup_dt_filters_and_cols(fl,me.doctype);if(!this.has_primary_filters)
|
||||
$dh(this.report_filters.first_page_filter);this.column_picker.refresh();$ds(me.body);}
|
||||
_r.ReportBuilder.prototype.set_filters_from_route=function(){var route=wn.get_route();if(route.length>3){for(var i=3;i<route.length;i++){var p=route[i].split('=');if(p.length==2){var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,p[0],p[1]);}}}}
|
||||
_r.ReportBuilder.prototype.add_filter=function(f){if(this.filter_fields_dict[f.parent+'\1'+f.label]){this.filter_fields_dict[f.parent+'\1'+f.label].df=f;}else{this.report_filters.add_field(f,f.parent,null,1);}}
|
||||
_r.ReportBuilder.prototype.setup_dt_filters_and_cols=function(fl,dt){var me=this;var lab=$a(me.filter_area,'div','filter_dt_head');lab.innerHTML='Filters for '+get_doctype_label(dt);var lab=$a(me.picker_area,'div','builder_dt_head');lab.innerHTML='Select columns for '+get_doctype_label(dt);var dt_fields=wn.meta.docfield_list[dt];for(var i=0;i<dt_fields.length;i++){fl[fl.length]=dt_fields[i];}
|
||||
var sf_list=locals.DocType[dt].search_fields?locals.DocType[dt].search_fields.split(','):[];for(var i in sf_list)sf_list[i]=strip(sf_list[i]);for(var i=0;i<fl.length;i++){var f=fl[i];if(f&&cint(f.in_filter)){me.report_filters.add_field(f,dt,in_list(sf_list,f.fieldname));}
|
||||
if(f&&!in_list(no_value_fields,f.fieldtype)&&f.fieldname!='docstatus'&&(!f.report_hide)){me.column_picker.add_field(f);}}
|
||||
me.set_sort_options();}
|
||||
_r.ReportBuilder.prototype.set_sort_options=function(l){var sl=this.orig_sort_list;empty_select(this.dt.sort_sel);if(l)sl=add_lists(l,this.orig_sort_list);if(!l)l=[];if(!l.length){l.push(['ID','name'])}
|
||||
for(var i=0;i<sl.length;i++){this.dt.add_sort_option(sl[i][0],sl[i][1]);}}
|
||||
_r.ReportBuilder.prototype.validate_permissions=function(onload){this.perm=get_perm(this.parent_dt?this.parent_dt:this.doctype);if(!this.perm[0][READ]){this.forbidden=1;if(user=='Guest'){msgprint('You must log in to view this page');}else{msgprint('No Read Permission');}
|
||||
window.back();return 0;}
|
||||
return 1;}
|
||||
_r.ReportBuilder.prototype.setup_doctype=function(onload){var me=this;if(!locals['DocType'][this.doctype]){this.load_doctype_from_server(onload);}else{for(var key in locals.DocField){var f=locals.DocField[key];if(f.fieldtype=='Table'&&f.options==this.doctype)
|
||||
this.parent_dt=f.parent;}
|
||||
if(!me.validate_permissions())
|
||||
return;me.validate_permissions();me.make_body();me.setup_filters_and_cols();if(onload)onload(me);}}
|
||||
_r.ReportBuilder.prototype.load_doctype_from_server=function(onload){var me=this;$c('webnotes.widgets.form.load.getdoctype',args={'doctype':this.doctype,'with_parent':1},function(r,rt){if(r.parent_dt)me.parent_dt=r.parent_dt;if(!me.validate_permissions())
|
||||
return;me.make_body();me.setup_filters_and_cols();if(onload)onload(me);});}
|
||||
_r.ReportBuilder.prototype.reset_report=function(){this.clear_criteria();this.mytabs.items['Select Columns'].show();this.mytabs.items['More Filters'].show();this.report_filters.refresh();this.column_picker.refresh();var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,'Saved',1);this.set_filter(dt,'Submitted',1);this.set_filter(dt,'Cancelled',0);this.column_picker.set_defaults();this.dt.clear_all();this.dt.sort_sel.value='ID';this.dt.page_len_sel.inp.value='50';this.dt.set_no_limit(0);this.dt.set_desc();this.set_filters_from_route();}
|
||||
_r.ReportBuilder.prototype.make_datatable=function(){var me=this;this.dt_area=$a(this.mytabs.items['Result'].body,'div');var clear_area=$a(this.mytabs.items['Result'].body,'div');clear_area.style.marginTop='8px';clear_area.style.textAlign='right';this.clear_btn=$a($a(clear_area,'span'),'button');this.clear_btn.innerHTML='Clear Settings';this.clear_btn.onclick=function(){me.reset_report();}
|
||||
var d=$a(clear_area,'span','',{marginLeft:'16px'});d.innerHTML='<span>Show Query: </span>';this.show_query=$a_input(d,'checkbox');this.show_query.checked=false;this.dt=new _r.DataTable(this.dt_area,'');this.dt.finder=this;this.dt.make_query=function(){var report=me;if(me.current_loaded&&me.sc_dict[me.current_loaded]){var sc=get_local('Search Criteria',me.sc_dict[me.current_loaded]);}
|
||||
if(sc)me.dt.search_criteria=sc;else me.dt.search_criteria=null;if(sc&&sc.server_script)me.dt.server_script=sc.server_script;else me.dt.server_script=null;for(var i=0;i<me.fn_list.length;i++){if(me[me.fn_list[i]])me.dt[me.fn_list[i]]=me[me.fn_list[i]];else me.dt[me.fn_list[i]]=null;}
|
||||
var fl=[];var docstatus_cl=[];var cl=[];var table_name=function(t){return'`tab'+t+'`';}
|
||||
var dis_filters_list=[];if(sc&&sc.dis_filters)
|
||||
var dis_filters_list=sc.dis_filters.split('\n');var t=me.column_picker.get_selected();for(var i=0;i<t.length;i++){fl.push(table_name(t[i].parent)+'.`'+t[i].fieldname+'` AS `'+t[i].parent+'.'+t[i].fieldname+'`');}
|
||||
me.selected_fields=fl;if(sc&&sc.add_col){var adv_fl=sc.add_col.split('\n');for(var i=0;i<adv_fl.length;i++){fl[fl.length]=adv_fl[i];}}
|
||||
me.dt.filter_vals={}
|
||||
add_to_filter=function(k,v,is_select){if(v==null)v='';if(!in_list(keys(me.dt.filter_vals),k)){me.dt.filter_vals[k]=v;}else{if(is_select)
|
||||
me.dt.filter_vals[k]+='\n'+v;else
|
||||
me.dt.filter_vals[k+'1']=v;}}
|
||||
for(var i=0;i<me.filter_fields.length;i++){var t=me.filter_fields[i];var v=t.get_value?t.get_value():'';if(t.df.fieldtype=='Select'){if(t.input.multiple){for(var sel_i=0;sel_i<v.length;sel_i++){add_to_filter(t.df.fieldname,v[sel_i],1);}
|
||||
if(!v.length)add_to_filter(t.df.fieldname,"",1);}else{add_to_filter(t.df.fieldname,v);}}else add_to_filter(t.df.fieldname,v);if(!in_list(dis_filters_list,t.df.fieldname)&&!t.df.ignore){if(t.df.fieldname=='docstatus'){if(t.df.label=='Saved'){if(t.get_value())docstatus_cl[docstatus_cl.length]=table_name(t.df.parent)+'.docstatus=0';else cl[cl.length]=table_name(t.df.parent)+'.docstatus!=0';}
|
||||
else if(t.df.label=='Submitted'){if(t.get_value())docstatus_cl[docstatus_cl.length]=table_name(t.df.parent)+'.docstatus=1';else cl[cl.length]=table_name(t.df.parent)+'.docstatus!=1';}
|
||||
else if(t.df.label=='Cancelled'){if(t.get_value())docstatus_cl[docstatus_cl.length]=table_name(t.df.parent)+'.docstatus=2';else cl[cl.length]=table_name(t.df.parent)+'.docstatus!=2';}}else{var fn='`'+t.df.fieldname+'`';var v=t.get_value?t.get_value():'';if(v){if(in_list(['Data','Link','Small Text','Text'],t.df.fieldtype)){cl[cl.length]=table_name(t.df.parent)+'.'+fn+' LIKE "'+v+'%"';}else if(t.df.fieldtype=='Select'){if(t.input.multiple){var tmp_cl=[];for(var sel_i=0;sel_i<v.length;sel_i++){if(v[sel_i]){tmp_cl[tmp_cl.length]=table_name(t.df.parent)+'.'+fn+' = "'+v[sel_i]+'"';}}
|
||||
if(tmp_cl.length)cl[cl.length]='('+tmp_cl.join(' OR ')+')';}else{cl[cl.length]=table_name(t.df.parent)+'.'+fn+' = "'+v+'"';}}else{var condition='=';if(t.sql_condition)condition=t.sql_condition;cl[cl.length]=table_name(t.df.parent)+'.'+fn+condition+'"'+v+'"';}}}}}
|
||||
me.dt.filter_vals.user=user;me.dt.filter_vals.user_email=user_email;me.filter_vals=me.dt.filter_vals;this.is_simple=0;if(sc&&sc.custom_query){this.query=repl(sc.custom_query,me.dt.filter_vals);this.is_simple=1;return}
|
||||
if(me.get_query){this.query=me.get_query();this.is_simple=1;}else{if(docstatus_cl.length)
|
||||
cl[cl.length]='('+docstatus_cl.join(' OR ')+')';if(sc&&sc.add_cond){var adv_cl=sc.add_cond.split('\n');for(var i=0;i<adv_cl.length;i++){cl[cl.length]=adv_cl[i];}}
|
||||
if(!fl.length){alert('You must select atleast one column to view');this.query='';return;}
|
||||
var tn=table_name(me.doctype);if(me.parent_dt){tn=tn+','+table_name(me.parent_dt);cl[cl.length]=table_name(me.doctype)+'.`parent` = '+table_name(me.parent_dt)+'.`name`';}
|
||||
if(sc&&sc.add_tab){var adv_tl=sc.add_tab.split('\n');tn=tn+','+adv_tl.join(',');}
|
||||
if(!cl.length)
|
||||
this.query='SELECT '+fl.join(',\n')+' FROM '+tn
|
||||
else
|
||||
this.query='SELECT '+fl.join(',')+' FROM '+tn+' WHERE '+cl.join('\n AND ');if(sc&&sc.group_by){this.query+=' GROUP BY '+sc.group_by;}
|
||||
this.query=repl(this.query,me.dt.filter_vals)}
|
||||
if(me.show_query.checked){this.show_query=1;}
|
||||
if(me.current_loaded)this.rep_name=me.current_loaded;else this.rep_name=me.doctype;}}
|
||||
_r.ReportBuilder.prototype.get_filter=function(dt,label){return this.filter_fields_dict[dt+FILTER_SEP+label];}
|
||||
_r.ReportBuilder.prototype.set_filter_properties=function(dt,label,properties){var f=this.filter_fields_dict[dt+FILTER_SEP+label];for(key in properties){f.df[key]=properties[key];}}
|
||||
_r.ReportFilters=function(rb){this.rb=rb;this.first_page_filter=$a(rb.mytabs.items['Result'].body,'div','finder_filter_area');this.filter_area=$a(rb.mytabs.items['More Filters'].body,'div','finder_filter_area');this.filter_fields_area=$a(this.filter_area,'div');}
|
||||
_r.ReportFilters.prototype.refresh=function(){var fl=this.rb.filter_fields
|
||||
for(var i=0;i<fl.length;i++){var f=fl[i];if(f.df.filter_hide){$dh(f.wrapper);}else{$ds(f.wrapper);}
|
||||
if(f.df.bold){if(f.label_cell)
|
||||
$y(f.label_cell,{fontWeight:'bold'})}else{if(f.label_cell)$y(f.label_cell,{fontWeight:'normal'})}
|
||||
if(f.df['report_default'])
|
||||
f.set_input(f.df['report_default']);if(f.df.in_first_page&&f.df.filter_cell){f.df.filter_cell.parentNode.removeChild(f.df.filter_cell);this.first_page_filter.appendChild(f.df.filter_cell);this.rb.has_primary_filters=1;$ds(this.first_page_filter);}}}
|
||||
_r.ReportFilters.prototype.add_date_field=function(cell,f,dt,is_custom){var my_div=$a(cell,'div','',{});var f1=copy_dict(f);f1.label='From '+f1.label;var tmp1=this.make_field_obj(f1,dt,my_div,is_custom);tmp1.sql_condition='>=';tmp1.bound='lower';var f2=copy_dict(f);f2.label='To '+f2.label;var tmp2=this.make_field_obj(f2,dt,my_div,is_custom);tmp2.sql_condition='<=';tmp2.bound='upper';}
|
||||
_r.ReportFilters.prototype.add_numeric_field=function(cell,f,dt,is_custom){var my_div=$a(cell,'div','',{});var f1=copy_dict(f);f1.label=f1.label+' >=';var tmp1=this.make_field_obj(f1,dt,my_div,is_custom);tmp1.sql_condition='>=';tmp1.bound='lower';var f2=copy_dict(f);f2.label=f2.label+' <=';var tmp2=this.make_field_obj(f2,dt,my_div,is_custom);tmp2.sql_condition='<=';tmp2.bound='upper';}
|
||||
_r.ReportFilters.prototype.make_field_obj=function(f,dt,parent,is_custom){var tmp=make_field(f,dt,parent,this.rb,false);tmp.not_in_form=1;tmp.in_filter=1;tmp.refresh();this.rb.filter_fields[this.rb.filter_fields.length]=tmp;this.rb.filter_fields_dict[f.parent+'\1'+f.label]=tmp;if(is_custom)tmp.is_custom=1;return tmp;}
|
||||
_r.ReportFilters.prototype.add_field=function(f,dt,in_primary,is_custom){var me=this;if(f.in_first_page)in_primary=true;var fparent=this.filter_fields_area;if(in_primary){fparent=this.first_page_filter;this.rb.has_primary_filters=1;}
|
||||
if(f.on_top){var cell=document.createElement('div');fparent.insertBefore(cell,fparent.firstChild);$y(cell,{width:'70%'});}else if(f.insert_before){var cell=document.createElement('div');fparent.insertBefore(cell,fparent[f.df.insert_before].filter_cell);$y(cell,{width:'70%'});}
|
||||
else
|
||||
var cell=$a(fparent,'div','',{width:'70%'});f.filter_cell=cell;if(f.fieldtype=='Date'){this.add_date_field(cell,f,dt);}else if(in_list(['Currency','Int','Float'],f.fieldtype)){this.add_numeric_field(cell,f,dt);}else if(!in_list(['Section Break','Column Break','Read Only','HTML','Table','Image','Button'],f.fieldtype)){var tmp=this.make_field_obj(f,dt,cell,is_custom);}
|
||||
if(f.fieldname!='docstatus')
|
||||
me.rb.orig_sort_list.push([f.label,'`tab'+f.parent+'`.`'+f.fieldname+'`']);if(f.def_filter)
|
||||
tmp.input.checked=true;}
|
||||
_r.ReportColumnPicker=function(rb){this.rb=rb;this.picker_area=$a(this.rb.mytabs.items['Select Columns'].body,'div','finder_picker_area');this.all_fields=[];this.sel_idx=0;this.make_body();}
|
||||
_r.ReportColumnPicker.prototype.make_body=function(){var t=make_table(this.picker_area,1,3,'100%',['35%','30%','35%'],{verticalAlign:'middle',textAlign:'center'});$a($td(t,0,0),'h3','',{marginBottom:'8px'}).innerHTML='Columns';this.unsel_fields=$a($td(t,0,0),'select','',{height:'200px',width:'100%',border:'1px solid #AAA'});this.unsel_fields.multiple=true;this.unsel_fields.onchange=function(){for(var i=0;i<this.options.length;i++)this.options[i].field.is_selected=this.options[i].selected;}
|
||||
var me=this;this.up_btn=$a($a($td(t,0,1),'div'),'button','',{width:'70px'});this.up_btn.innerHTML='Up ↑';this.up_btn.onclick=function(){me.move_up();}
|
||||
this.add_all=$a($a($td(t,0,1),'div'),'button','',{width:'40px'});this.add_all.innerHTML='>>';this.add_all.onclick=function(){me.move(me.unsel_fields,'add',1);}
|
||||
this.add_btn=$a($a($td(t,0,1),'div'),'button','',{width:'110px'});this.add_btn.innerHTML='<b>Add ></b>';this.add_btn.onclick=function(){me.move(me.unsel_fields,'add');}
|
||||
this.remove_btn=$a($a($td(t,0,1),'div'),'button','',{width:'110px'});this.remove_btn.innerHTML='<b>< Remove</b>';this.remove_btn.onclick=function(){me.move(me.sel_fields,'remove');}
|
||||
this.remove_all=$a($a($td(t,0,1),'div'),'button','',{width:'40px'});this.remove_all.innerHTML='<<';this.remove_all.onclick=function(){me.move(me.sel_fields,'remove',1);}
|
||||
this.dn_btn=$a($a($td(t,0,1),'div'),'button','',{width:'70px'});this.dn_btn.innerHTML='Down ↓';this.dn_btn.onclick=function(){me.move_down();}
|
||||
$a($td(t,0,2),'h3','',{marginBottom:'8px'}).innerHTML='Selected Columns';this.sel_fields=$a($td(t,0,2),'select','',{height:'200px',width:'100%',border:'1px solid #AAA'});this.sel_fields.multiple=true;this.sel_fields.onchange=function(){for(var i=0;i<this.options.length;i++)this.options[i].field.is_selected=this.options[i].selected;}}
|
||||
_r.ReportColumnPicker.prototype.get_by_sel_idx=function(s,idx){for(var j=0;j<s.options.length;j++){if(s.options[j].field.sel_idx==idx)
|
||||
return s.options[j].field;}
|
||||
return{}}
|
||||
_r.ReportColumnPicker.prototype.move_up=function(){var s=this.sel_fields;for(var i=1;i<s.options.length;i++){if(s.options[i].selected){s.options[i].field.sel_idx--;this.get_by_sel_idx(s,i-1).sel_idx++;}}
|
||||
this.refresh();}
|
||||
_r.ReportColumnPicker.prototype.move_down=function(){var s=this.sel_fields;if(s.options.length<=1)return;for(var i=s.options.length-2;i>=0;i--){if(s.options[i].selected){this.get_by_sel_idx(s,i+1).sel_idx--;s.options[i].field.sel_idx++;}}
|
||||
this.refresh();}
|
||||
_r.ReportColumnPicker.prototype.move=function(s,type,all){for(var i=0;i<s.options.length;i++){if(s.options[i].selected||all){if(type=='add'){s.options[i].field.selected=1;s.options[i].field.sel_idx=this.sel_idx;this.sel_idx++;}else{s.options[i].field.selected=0;s.options[i].field.sel_idx=0;this.sel_idx--;}}}
|
||||
this.refresh();}
|
||||
_r.ReportColumnPicker.prototype.refresh=function(){var ul=[];var sl=[];for(var i=0;i<this.all_fields.length;i++){var o=this.all_fields[i];if(o.selected){sl.push(o);if(this.rb.dt)this.rb.dt.set_sort_option_disabled(o.df.label,0);}else{ul.push(o);if(this.rb.dt)this.rb.dt.set_sort_option_disabled(o.df.label,1);}}
|
||||
ul.sort(function(a,b){return(cint(a.df.idx)-cint(b.df.idx))});sl.sort(function(a,b){return(cint(a.sel_idx)-cint(b.sel_idx))})
|
||||
for(var i=0;i<sl.length;i++){sl[i].sel_idx=i;}
|
||||
this.set_options(this.unsel_fields,ul);this.set_options(this.sel_fields,sl);}
|
||||
_r.ReportColumnPicker.prototype.set_options=function(s,l){empty_select(s);for(var i=0;i<l.length;i++){var v=l[i].df.parent+'.'+l[i].df.label;var v_label=get_doctype_label(l[i].df.parent)+'.'+l[i].df.label;var o=new Option(v_label,v,false,false);o.field=l[i];if(o.field.is_selected)o.selected=1;s.options[s.options.length]=o;}}
|
||||
_r.ReportColumnPicker.prototype.clear=function(){this.sel_idx=0;for(var i=0;i<this.all_fields.length;i++){this.all_fields[i].selected=0;}
|
||||
this.refresh();}
|
||||
_r.ReportColumnPicker.prototype.get_selected=function(){var sl=[];for(var i=0;i<this.all_fields.length;i++){var o=this.all_fields[i];if(o.selected){sl[sl.length]=o.df;o.df.sel_idx=o.sel_idx;}}
|
||||
return sl.sort(function(a,b){return(cint(a.sel_idx)-cint(b.sel_idx))});}
|
||||
_r.ReportColumnPicker.prototype.set_defaults=function(){for(var i=0;i<this.all_fields.length;i++){if(this.all_fields[i].selected_by_default)
|
||||
this.all_fields[i].selected=1;}}
|
||||
_r.ReportColumnPicker.prototype.add_field=function(f){if(!f.label)return;var by_default=(f.in_filter)?1:0;this.all_fields.push({selected:by_default,df:f,sel_idx:(by_default?this.sel_idx:0),selected_by_default:by_default});this.sel_idx+=by_default;}
|
||||
_r.ReportColumnPicker.prototype.set=function(dt,label,selected){for(var i=0;i<this.all_fields.length;i++){if(this.all_fields[i].df.parent==dt&&this.all_fields[i].df.label==label){this.all_fields[i].selected=selected;this.all_fields[i].sel_idx=this.sel_idx;this.sel_idx+=cint(selected);this.refresh();return;}}}
|
||||
/*
|
||||
* lib/js/legacy/widgets/report_builder/datatable.js
|
||||
*/
|
||||
_r.scroll_head=function(ele){var h=ele.childNodes[0];h.style.top=cint(ele.scrollTop)+'px';}
|
||||
_r.DataTable=function(html_fieldname,dt,repname,hide_toolbar){var me=this;if(html_fieldname.substr){var html_field=cur_frm.fields_dict[html_fieldname];html_field.onrefresh=function(){if(me.docname!=cur_frm.docname){me.clear_all();me.docname=cur_frm.docname;}}
|
||||
var parent=html_field.wrapper;datatables[html_fieldname]=this;}else{var parent=html_fieldname;}
|
||||
this.start_rec=1;this.page_len=50;this.repname=repname;this.dt=dt;this.no_limit=false;this.query='';this.has_index=1;this.has_headings=1;this.disabled_options={};this.levels=[];if(this.dt){var tw=$a(parent,'div');var t=$a(tw,'div','link_type');t.style.cssFloat='right';$h(tw,'14px');t.style.margin='2px 0px';t.style.fontSize='11px';t.onclick=function(){new_doc(me.dt);}
|
||||
t.innerHTML='New '+this.dt;}
|
||||
if(!hide_toolbar)this.make_toolbar(parent);this.wrapper=$a(parent,'div','report_tab');$h(this.wrapper,cint(screen.height*0.35)+'px');this.wrapper.onscroll=function(){_r.scroll_head(this);}
|
||||
this.hwrapper=$a(this.wrapper,'div','report_head_wrapper');this.twrapper=$a(this.wrapper,'div','report_tab_wrapper');this.no_data_tag=$a(this.wrapper,'div','report_no_data');this.no_data_tag.innerHTML='No Records Found';this.fetching_tag=$a(this.wrapper,'div','',{height:'100%',background:'url("images/lib/ui/square_loading.gif") center no-repeat',display:'none'});}
|
||||
_r.DataTable.prototype.add_icon=function(parent,imgsrc){var i=$a(parent,'img');i.style.padding='2px';i.style.cursor='pointer';i.setAttribute('src','images/lib/icons/'+imgsrc+'.gif');return i;}
|
||||
_r.DataTable.prototype.set_no_limit=function(v){if(v){this.no_limit=1;$dh(this.page_len_sel.wrapper);}else{this.no_limit=0;$ds(this.page_len_sel.wrapper);}}
|
||||
_r.DataTable.prototype.make_toolbar=function(parent){var me=this;this.hbar=$a(parent,'div','',{margin:'8px 0px 16px 0px'});var ht=make_table(this.hbar,1,3,'100%',['40%','40%','20%'],{verticalAlign:'middle'});var div=$a($td(ht,0,0),'div');var t=make_table($td(ht,0,1),1,6,null,[null,null,null,'20px',null,null],{verticalAlign:'middle'});$td(t,0,0).innerHTML='Sort By:';$y($td(t,0,1),{textAlign:'right',paddingRight:'4px'});this.sort_sel=$a($td(t,0,2),'select','',{width:'100px'});this.sort_sel.onchange=function(){me.start_rec=1;me.run();}
|
||||
this.sort_icon=this.add_icon($td(t,0,3),'arrow_down');this.sort_order='DESC';this.sort_icon.onclick=function(){if(me.sort_order=='ASC')me.set_desc();else me.set_asc();me.start_rec=1;me.run();}
|
||||
$td(t,0,4).innerHTML='Per Page:';$y($td(t,0,4),{textAlign:'right',paddingRight:'4px'});var s=new SelectWidget($td(t,0,5),['50','100','500','1000'],'70px');s.inp.value='50';s.inp.onchange=function(){me.page_len=flt(this.value);}
|
||||
this.page_len_sel=s;var c1=$td(ht,0,2);c1.style.textAlign='right';var ic=this.add_icon(c1,'resultset_first');ic.onclick=function(){me.start_rec=1;me.run();}
|
||||
var ic=this.add_icon(c1,'resultset_previous');ic.onclick=function(){if(me.start_rec-me.page_len<=0)return;me.start_rec=me.start_rec-me.page_len;me.run();}
|
||||
this.has_next=false;var ic=this.add_icon(c1,'resultset_next');ic.onclick=function(){if(!me.has_next)return;me.start_rec=me.start_rec+me.page_len;me.run();}}
|
||||
_r.DataTable.prototype.set_desc=function(){this.sort_icon.src='images/lib/icons/arrow_down.gif';this.sort_order='DESC';}
|
||||
_r.DataTable.prototype.set_asc=function(icon){this.sort_icon.src='images/lib/icons/arrow_up.gif';this.sort_order='ASC';}
|
||||
_r.DataTable.prototype.set_sort_option_disabled=function(label,disabled){var s=this.sort_sel;if(disabled){for(var i=0;i<s.options.length;i++){if(s.options[i]&&s.options[i].text==label){this.disabled_options[label]=s.options[i];s.remove(i);}}}else{if(this.disabled_options[label]){try{s.add(this.disabled_options[label],s.options[s.options.length-1]);}catch(e){try{s.add(this.disabled_options[label],s.options.length-1);}catch(e){}}
|
||||
this.disabled_options[label]=null;}}}
|
||||
_r.DataTable.prototype.add_sort_option=function(label,val){var s=this.sort_sel;s.options[s.options.length]=new Option(label,val,false,s.options.length==0?true:false);}
|
||||
_r.DataTable.prototype.update_query=function(no_limit){if((_r.rb_con.cur_rb&&_r.rb_con.cur_rb.get_query)||(this.search_criteria&&this.search_criteria.custom_query)){}else{if(!sel_val(this.sort_sel)){this.sort_sel.selectedIndex=0;}
|
||||
this.query+=NEWLINE
|
||||
+' ORDER BY '+sel_val(this.sort_sel)
|
||||
+' '+this.sort_order;}
|
||||
if(no_limit||this.no_limit){if(this.show_query)alert(this.query);return;}
|
||||
this.query+=' LIMIT '+(this.start_rec-1)+','+this.page_len;if(this.show_query)
|
||||
alert(this.query);}
|
||||
_r.DataTable.prototype._get_query=function(no_limit){$dh(this.no_data_tag);this.show_query=0;if(this.make_query)
|
||||
this.make_query();this.update_query(no_limit);}
|
||||
_r.DataTable.prototype.run=function(){if(this.validate&&!this.validate())
|
||||
return;if(_r.rb_con.cur_rb){if(_r.rb_con.cur_rb.large_report==1){msgprint("This is a very large report and cannot be shown in the browser as it is likely to make your browser very slow.<br><br>Please click on 'Export' to open in a spreadsheet");return;}
|
||||
_r.rb_con.cur_rb.mytabs.items['Result'].expand();}
|
||||
var me=this;this._get_query();if(this.set_data){this.show_result(this.set_data);this.set_data=null;return;}
|
||||
$ds(this.fetching_tag);if($.browser.mozilla)this.clear_all();var args={'query':me.query,'report_name':'_r.DataTable','show_deleted':1,'sc_id':me.search_criteria?me.search_criteria.name:'','filter_values':me.filter_vals?docstring(me.filter_vals):'','roles':'["'+user_roles.join('","')+'"]'}
|
||||
if(this.is_simple)args.is_simple=1;$c('webnotes.widgets.query_builder.runquery',args,function(r,rt){$dh(me.fetching_tag);me.show_result(r,rt);});}
|
||||
_r.DataTable.prototype.clear_all=function(){if(this.htab&&this.htab.parentNode){this.htab.parentNode.removeChild(this.htab);delete this.htab;}
|
||||
if(this.tab&&this.tab.parentNode){this.tab.parentNode.removeChild(this.tab);delete this.tab;}
|
||||
$dh(this.no_data_tag);}
|
||||
_r.DataTable.prototype.has_data=function(){if(this.htab&&this.htab.rows.length)return 1;else return 0;}
|
||||
_r.DataTable.prototype.show_result=function(r,rt){var me=this;this.clear_all();this.rset=eval(r.values);if(this.rset&&this.rset.length){if(this.has_headings){this.htab=$a(this.hwrapper,'table');$y(this.twrapper,{top:'25px',borderTop:'0px'});}
|
||||
this.tab=$a(this.twrapper,'table');this.colwidths=eval(r.colwidths);this.coltypes=eval(r.coltypes);this.coloptions=eval(r.coloptions);this.colnames=eval(r.colnames);$y(this.tab,{tableLayout:'fixed'});if(this.beforetableprint)this.beforetableprint(this);if(this.has_headings)this.make_head_tab(this.colnames);var start=this.start_rec;var rset_len=this.rset.length;if(rset_len>1000){msgprint("Showing only 1000 records out of "+rset_len+". Use 'Export' to see all records");rset_len=1000;}
|
||||
for(var vi=0;vi<rset_len;vi++){var row=this.tab.insertRow(vi);if(this.has_index){var c0=row.insertCell(0);$w(c0,'30px');$a(c0,'div','',{width:'23px'}).innerHTML=start;}
|
||||
start++;for(var ci=0;ci<this.rset[vi].length;ci++){this.make_data_cell(vi,ci,this.rset[vi][ci]);}
|
||||
if(this.afterrowprint){row.data_cells={};row.data={};for(var ci=0;ci<this.colnames.length;ci++){row.data[this.colnames[ci]]=this.rset[vi][ci];row.data_cells[this.colnames[ci]]=row.cells[ci+1];}f
|
||||
this.afterrowprint(row);}}
|
||||
if(this.rset.length&&this.rset.length>=this.page_len)this.has_next=true;if(r.style){for(var i=0;i<r.style.length;i++){$yt(this.tab,r.style[i][0],r.style[i][1],r.style[i][2]);}}
|
||||
if(this.aftertableprint)this.aftertableprint(this.tab);}else{$ds(this.no_data_tag);}}
|
||||
_r.DataTable.prototype.get_col_width=function(i){if(this.colwidths&&this.colwidths.length&&this.colwidths[i])
|
||||
return cint(this.colwidths[i])+'px';else return'100px';}
|
||||
_r.DataTable.prototype.make_head_tab=function(colnames){var r0=this.htab.insertRow(0);if(this.has_index){var c0=r0.insertCell(0);c0.className='report_head_cell';$w(c0,'30px');$a(c0,'div').innerHTML='Sr';this.total_width=30;}
|
||||
for(var i=0;i<colnames.length;i++){var w=this.get_col_width(i);this.total_width+=cint(w);var c=r0.insertCell(r0.cells.length);c.className='report_head_cell';if(w)$w(c,w);$a(c,'div').innerHTML=colnames[i];c.val=colnames[i];}
|
||||
$w(this.htab,this.total_width+'px');$w(this.tab,this.total_width+'px');}
|
||||
_r.DataTable.prototype.make_data_cell=function(ri,ci,val){var row=this.tab.rows[ri];var c=row.insertCell(row.cells.length);if(row.style.color)
|
||||
c.style.color=row.style.color;if(row.style.backgroundColor)
|
||||
c.style.backgroundColor=row.style.backgroundColor;if(row.style.fontWeight)
|
||||
c.style.fontWeight=row.style.fontWeight;if(row.style.fontSize)
|
||||
c.style.fontSize=row.style.fontSize;var w=this.get_col_width(ci);if(w)$w(c,w);c.val=val;var me=this;c.div=$a(c,'div','',{width:(cint(w)-7)+'px'});$s(c.div,val,this.coltypes[ci],this.coloptions[ci])}
|
||||
_r.DataTable.prototype.do_print=function(){this._get_query(true);args={query:this.query,title:this.rep_name?this.rep_name:this.dt,colnames:null,colwidhts:null,coltypes:null,has_index:this.has_index,has_headings:this.has_headings,check_limit:1,is_simple:(this.is_simple?'Yes':''),sc_id:(this.search_criteria?this.search_criteria.name:''),filter_values:docstring(this.filter_vals),finder:this.finder?this.finder:null};wn.require('js/print_query.js');_p.print_query=new _p.PrintQuery();_p.print_query.show_dialog(args);}
|
||||
_r.DataTable.prototype.do_export=function(){this._get_query(true);var me=this;export_query(this.query,function(q){export_csv(q,(me.rep_name?me.rep_name:me.dt),(me.search_criteria?me.search_criteria.name:''),me.is_simple,docstring(me.filter_vals));});}
|
||||
_r.DataTable.prototype.do_calc=function(){_r.show_calc(this.tab,this.colnames,this.coltypes,1);}
|
||||
_r.DataTable.prototype.get_col_data=function(colname){var ci=0;if(!this.htab)return[];for(var i=1;i<this.htab.rows[0].cells.length;i++){var hc=this.htab.rows[0].cells[i];if(hc.val==colname){ci=i;break;}}
|
||||
var ret=[];for(var ri=0;ri<this.tab.rows.length;ri++){ret[ret.length]=this.tab.rows[ri].cells[ci].val;}
|
||||
return ret;}
|
||||
_r.DataTable.prototype.get_html=function(){var w=document.createElement('div');w=$a(w,'div');w.style.marginTop='16px';var tab=$a(w,'table');var add_head_style=function(c,w){c.style.fontWeight='bold';c.style.border='1px solid #000';c.style.padding='2px';if(w)$w(c,w);return c;}
|
||||
var add_cell_style=function(c){c.style.padding='2px';c.style.border='1px solid #000';return c;}
|
||||
tab.style.borderCollapse='collapse';var hr=tab.insertRow(0);var c0=add_head_style(hr.insertCell(0),'30px');c0.innerHTML='Sr';for(var i=1;i<this.htab.rows[0].cells.length;i++){var hc=this.htab.rows[0].cells[i];var c=add_head_style(hr.insertCell(i),hc.style.width);c.innerHTML=hc.innerHTML;}
|
||||
for(var ri=0;ri<this.tab.rows.length;ri++){var row=this.tab.rows[ri];var dt_row=tab.insertRow(tab.rows.length);for(var ci=0;ci<row.cells.length;ci++){var c=add_cell_style(dt_row.insertCell(ci));c.innerHTML=row.cells[ci].innerHTML;}}
|
||||
return w.innerHTML;}
|
||||
/*
|
||||
* lib/js/legacy/widgets/report_builder/calculator.js
|
||||
*/
|
||||
_r.calc_dialog=null;_r.show_calc=function(tab,colnames,coltypes,add_idx){if(!add_idx)add_idx=0;if(!tab||!tab.rows.length){msgprint("No Data");return;}
|
||||
if(!_r.calc_dialog){var d=new Dialog(400,400,"Calculator")
|
||||
d.make_body([['Select','Column'],['Data','Sum'],['Data','Average'],['Data','Min'],['Data','Max']])
|
||||
d.widgets['Sum'].readonly='readonly';d.widgets['Average'].readonly='readonly';d.widgets['Min'].readonly='readonly';d.widgets['Max'].readonly='readonly';d.widgets['Column'].onchange=function(){d.set_calc();}
|
||||
d.set_calc=function(){var cn=sel_val(this.widgets['Column']);var cidx=0;var sum=0;var avg=0;var minv=null;var maxv=null;for(var i=0;i<this.colnames.length;i++){if(this.colnames[i]==cn){cidx=i+add_idx;break;}}
|
||||
for(var i=0;i<this.datatab.rows.length;i++){var c=this.datatab.rows[i].cells[cidx];var v=c.div?flt(c.div.innerHTML):flt(c.innerHTML);sum+=v;if(minv==null)minv=v;if(maxv==null)maxv=v;if(v>maxv)maxv=v;if(v<minv)minv=v;}
|
||||
d.widgets['Sum'].value=fmt_money(sum);d.widgets['Average'].value=fmt_money(sum/this.datatab.rows.length);d.widgets['Min'].value=fmt_money(minv);d.widgets['Max'].value=fmt_money(maxv);_r.calc_dialog=d;}
|
||||
d.onshow=function(){var cl=[];for(var i in _r.calc_dialog.colnames){if(in_list(['Currency','Int','Float'],_r.calc_dialog.coltypes[i]))
|
||||
cl.push(_r.calc_dialog.colnames[i]);}
|
||||
if(!cl.length){this.hide();alert("No Numeric Column");return;}
|
||||
var s=this.widgets['Column'];empty_select(s);add_sel_options(s,cl);if(s.inp)s.inp.value=cl[0];else s.value=cl[0];this.set_calc();}
|
||||
_r.calc_dialog=d;}
|
||||
_r.calc_dialog.datatab=tab;_r.calc_dialog.colnames=colnames;_r.calc_dialog.coltypes=coltypes;_r.calc_dialog.show();}
|
82
public/js/wn-web.js
Normal file
@ -0,0 +1,82 @@
|
||||
window._version_number = "d9f42d1e15307de62f68d890d4e40adbe2472a85153ddc965775bebd";
|
||||
window.home_page = "Login Page";
|
||||
// footer signup widget
|
||||
// automatically adds it to the .layout-main div of the page
|
||||
// adds events and also random goodies.
|
||||
|
||||
erpnext.set_request_signup = function(page_name) {
|
||||
|
||||
// goodies
|
||||
var goodies = [
|
||||
"ERPNext also contains a module to build your website. \
|
||||
The way it works is, when you log out, the app becomes your website. \
|
||||
This website is generated from ERPNext.",
|
||||
|
||||
"You can add custom fields to your transactions in ERPNext to capture specific information about your business.",
|
||||
|
||||
"All forms in ERPNext can be customized, if you feel there are features you do not want to use, you can hide them.",
|
||||
|
||||
"You can email transactions like Quotations and Invoices directly from the system. You can also set this process to become automatic",
|
||||
|
||||
"You can create your own Roles and assign user to those roles. You can also set detailed permissions for each role in transactions.",
|
||||
|
||||
"ERPNext allows you to assign any transaction like an Invoice or Customer Issue to a user. You can also add comments on any transaction."
|
||||
|
||||
];
|
||||
|
||||
|
||||
// add the footer
|
||||
|
||||
$('#page-' + page_name + ' .layout-main').append('<div class="page-footer">\
|
||||
<h2 style="padding: 0px">Try before you buy. \
|
||||
Request a 30-day Free Trial.</h2><br>\
|
||||
\
|
||||
<input name="company_name" type="text" placeholder="Company Name"> \
|
||||
<input name="sender_name" type="text" placeholder="Your Name"> \
|
||||
<input name="email" type="text" placeholder="Email"> \
|
||||
<input name="password" type="password" placeholder="Password"> \
|
||||
<button class="btn btn-success btn-small btn-request">Request</button>\
|
||||
\
|
||||
<p>Note: Free trials usually take one business day to setup. \
|
||||
Please fill out your genuine information because we verify \
|
||||
your name and company before setting up a demo to \
|
||||
ensure that spammers don\'t crash our servers. \
|
||||
If you would like to see something right now, \
|
||||
<a href="#!demo">jump to the demo.</a></p>\
|
||||
\
|
||||
<p style="font-size: 90%; margin-top: 10px;">\
|
||||
<i class="icon-hand-right"></i> <b>ERPNext Goodies:</b> <span class="goodie">'
|
||||
|
||||
+ goodies[parseInt(Math.random() * goodies.length)]+
|
||||
|
||||
'</goodie></p>\
|
||||
</span>');
|
||||
|
||||
// bind the events
|
||||
|
||||
$('#page-'+page_name+' .btn-request').click(function() {
|
||||
|
||||
var page = $('#page-' + wn.container.page.page_name);
|
||||
var args = {
|
||||
sender_name: page.find('[name="sender_name"]').val(),
|
||||
company_name: page.find('[name="company_name"]').val(),
|
||||
email: page.find('[name="email"]').val(),
|
||||
password: page.find('[name="password"]').val()
|
||||
}
|
||||
|
||||
if(!(args.sender_name && args.company_name && args.email && args.password)) {
|
||||
msgprint("All fields are necessary. Please try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
erpnext.send_message({
|
||||
subject:'New Trial Request',
|
||||
sender: page.find('[name="sender_name"]').val(),
|
||||
message: args,
|
||||
callback: function() {
|
||||
page.find(':input').val('');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
57
temp.py
@ -1,57 +0,0 @@
|
||||
license = """ERPNext - web based ERP (http://erpnext.com)
|
||||
Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>."""
|
||||
|
||||
license2 = """Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
|
||||
|
||||
MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
import os
|
||||
#clicense = '\n'.join([('# ' + l) for l in license2.split('\n')])
|
||||
cnt = 0
|
||||
for wt in os.walk('.'):
|
||||
for fname in wt[2]:
|
||||
if fname.endswith('.js'):
|
||||
cnt += 1
|
||||
#path = os.path.join(wt[0], fname)
|
||||
#with open(path, 'r') as codefile:
|
||||
# codetxt = codefile.read()
|
||||
|
||||
#if codetxt.strip():
|
||||
# with open(path, 'w') as codefile:
|
||||
# codefile.write(clicense + '\n\n' + codetxt)
|
||||
|
||||
# print 'updated in ' + path
|
||||
print cnt
|
18
todo.md
@ -1,18 +0,0 @@
|
||||
x icons - msgprint / toolbar
|
||||
x history integration
|
||||
x loading bar
|
||||
x blank.html issues
|
||||
x double (init) loading issue
|
||||
x redirect (sid) issue
|
||||
x new buttons
|
||||
x tinymce issues
|
||||
x breakup - form
|
||||
x breakup - report
|
||||
|
||||
- menus & integration with feature settings
|
||||
|
||||
- release
|
||||
|
||||
- use wn.require to load forms, reports
|
||||
- use wn.xmlhttp
|
||||
- try and breakup wnframework
|