Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename

This commit is contained in:
Nabin Hait 2012-04-20 13:59:22 +05:30
commit f19bb52b2a
16 changed files with 77 additions and 716 deletions

View File

@ -20,8 +20,9 @@ def execute():
'Invest 80 Declaration Detail', 'IT Checklist', 'Chapter VI A Detail', 'Declaration Detail',
'Personalize', 'Salary Slip Control Panel',
],
'Page' : ['File Browser'],
'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan']
'Page' : ['File Browser', 'Bill of Materials'],
'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan'],
'Module Def': ['Knowledge Base']
}
for d in del_rec:

View File

@ -1,44 +0,0 @@
<div class="layout_wrapper">
<div id="bom_header">&nbsp;</div>
<!--
<div style="color: #444444;" mce_style="color: #444444;">
<table style="width: 100%;" border="0">
<tbody>
<tr>
<td class="standard_title" style="width: 70%;">Bill of Materials</td>
<td style="width: 30%; text-align: right; vertical-align: top;"><span class="link_type" style="vertical-align:top" mce_style="vertical-align:top"> <img style="cursor:pointer" mce_style="cursor:pointer" onclick="nav_obj.show_last_open()" src="images/ui/close_btn.gif" mce_src="images/ui/close_btn.gif" alt="" /> </span></td>
</tr>
</tbody>
</table>
</div>
--> <!-- table.coa_toolbar td { vertical-align: middle; } --> <!--
<div style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;" mce_style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;">
<table class="coa_toolbar" border="0" cellspacing="2px">
<tbody>
<tr>
<td>Item Group:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_group"></select></td>
<td>Enter Item Code:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_code"></select></td>
<td>Enter BOM No:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_bom_no"></select></td>
<td>
<div id="bom_refresh"></div>
</td>
<td>
<div id="bom_calculate_cost"></div>
</td>
</tr>
</tbody>
</table>
</div>
--> <!--
<div style="margin: 0px 16px 16px; overflow: auto; padding-top: 4px; height: 300px;">-->
<div style="overflow: auto; margin-top: 8px; padding-top: 4px; height: 300px;">
<div style="width: 900px;">
<div id="bom_head_op" style="display: none;"></div>
<div id="bom_head_it" style="display: none; border-bottom: 2px solid #444;"></div>
<div id="bom_tree"></div>
</div>
</div>
</div>

View File

@ -1,524 +0,0 @@
// 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/>.
pscript['onload_Bill of Materials'] = function() {
wn.require('lib/js/legacy/widgets/tree.js');
// header and toolbar
var h = new PageHeader('bom_header','Bill of Materials','BOM gives the breakdown of cost for product');
var dv = $a(h.toolbar_area,'div','',{margin:'4px 0px'});
var tbl = make_table(dv, 1,3,'480px',[],{padding:'4px', width:'160px'});
var sel = $a($td(tbl,0,0),'select','',{width:'160px'});
sel.id = 'bom_item_group';
var sel = $a($td(tbl,0,1),'select','',{width:'160px'});
sel.id = 'bom_item_code'; sel.innerHTML = 'Select Item Code...'; sel.disabled = 1;
var sel = $a($td(tbl,0,2),'select','',{width:'160px'});
sel.id = 'bom_bom_no'; sel.innerHTML = 'Select Bom No...'; sel.disabled = 1;
h.add_button('Calculate Cost', function(){ pscript.bom_calculate_cost(pscript.bom_no); },1,'ui-icon-calculator');
h.add_button('Refresh', function(){ pscript.bom_refresh(); },0,'ui-icon-refresh');
h.add_button('Collapse All', function(){pscript.collapse_all();},0,'');
// select for Item Group
//$i('bom_item_group').style.width = '180px';
// $i('bom_item_code').style.width = '110px';
// $i('bom_bom_no').style.width = '150px';
$i('bom_tree').innerHTML = 'Please Select Item Group';
add_sel_options($i('bom_item_group'), ['Loading ... ']);
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_group'}, function(r,rt) {
pscript.item_group = r.message.split('~~~');
empty_select($i('bom_item_group'));
// add_sel_options($i('bom_item_group'), add_lists([' '], pscript.item_group), ' ');
add_sel_options($i('bom_item_group'), add_lists(['Select Item Group...'], pscript.item_group), 'Select Item Group...');
$i('bom_item_group').onchange = function() {
//$i('bom_item_code').innerHTML = '';
// $i('bom_bom_no').innerHTML = '';
$i('bom_head_op').innerHTML = '';
$i('bom_head_it').innerHTML = '';
$i('bom_tree').innerHTML = 'Please Select Item Code';
pscript.bom_select_item_code(sel_val(this));
}
});
}
pscript.bom_select_item_code = function(item_group) {
//select for Item Code
add_sel_options($i('bom_item_code'), ['Loading ... ']);
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_code', 'arg':item_group}, function(r,rt) {
pscript.item_code = r.message.split('~~~');
empty_select($i('bom_item_code'));
add_sel_options($i('bom_item_code'), add_lists(['Select Item Code...'], pscript.item_code), 'Select Item Code...');
if(sel_val($i('bom_item_code')) == 'Select Item Group...'){
$i('bom_item_code').disabled = 1;
$i('bom_bom_no').disabled = 1;
}
else{ $i('bom_item_code').disabled = 0; }
$i('bom_item_code').onchange = function() {
// $i('bom_bom_no').innerHTML = '';
$i('bom_head_op').innerHTML = '';
$i('bom_head_it').innerHTML = '';
$i('bom_tree').innerHTML = 'Please Select BOM NO.';
pscript.bom_select_bom_no(sel_val(this));
}
});
}
pscript.bom_select_bom_no = function(item_code) {
//select for BOM NO
add_sel_options($i('bom_bom_no'), ['Loading ... ']);
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_bom_no', 'arg':item_code}, function(r,rt) {
var bom_list = r.message.split('~~~');
empty_select($i('bom_bom_no'));
empty_select($i('bom_bom_no'));
add_sel_options($i('bom_bom_no'), add_lists(['Select Bom No...'], bom_list), 'Select Bom No...');
if(sel_val($i('bom_item_code')) == 'Select Item Code...'){
$i('bom_bom_no').disabled = 1;
}
else{
$i('bom_bom_no').disabled = 0;
}
$i('bom_bom_no').onchange = function() {
$i('bom_head_op').innerHTML = '';
$i('bom_head_it').innerHTML = '';
$i('bom_tree').innerHTML = 'Loading...';
pscript.show_bom(); }
});
}
// Refresh Function
pscript.bom_refresh = function() {
$i('bom_head_op').innerHTML = '';
$i('bom_head_it').innerHTML = '';
$i('bom_tree').innerHTML = 'Refreshing....';
pscript.show_bom();
}
//Calculate Cost Function
pscript.bom_calculate_cost = function() {
$i('bom_head_op').innerHTML = '';
$i('bom_head_it').innerHTML = '';
$i('bom_tree').innerHTML = ' Calculating Cost...';
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'calculate_cost', 'arg':pscript.bom_no}, function(r,rt) {
var calculated = r.message;
if (calculated == 'calculated') {pscript.show_bom();}
else {$i('bom_tree').innerHTML = "Not available";}
});
}
pscript.collapse_all = function(){
pscript.bom_tree.collapseall()
}
pscript.show_bom = function () {
pscript.item_code = $i('bom_item_code').value;
pscript.bom_no = $i('bom_bom_no').value;
// $i('bom_refresh').innerHTML = '';
//$i('bom_refresh').innerHTML = "<input type='button' value='Refresh' onClick='javascript:pscript.bom_refresh()' />";
//$i('bom_calculate_cost').innerHTML = "<input type='button' value='Calculate Cost' onClick='javascript:pscript.bom_calculate_cost(pscript.bom_no)' />";
if (pscript.item_code == "") {
alert("Please Enter Item Code");
return;
}
if (pscript.bom_no == "") {
alert("Please Enter BOM No");
return;
}
$ds('bom_head_op');
$ds('bom_head_it');
$ds('bom_tree');
pscript.bom_onexp = function(node) {
//alert("Server Call")
if(!node.expanded_once) {
$ds(node.loading_div);
if (!node.is_item){
// We will get List Of Items and BOM for particular Operation
data = "{'op_no':'" + node.text[1] +"','bom_no':'" + node.text[3] +"'}";
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_bom', 'arg':data},
function(r,rt) {
$dh(node.loading_div);
var nl = r.message;
for(var i=0; i<nl.length; i++) {
if (nl[i][8] == 1) {
pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/box.png', null, null);
}
else {
pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/package.png', null, pscript.bom_onexp);
}
}
});
} else {
//alert("bom_no:%s"%node.text[2])
//We will get List Of Operations for particular Item and BOM
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':node.text[3]},
function(r,rt) {
$dh(node.loading_div);
var nl = r.message;
for(var i=0; i<nl.length; i++) {
pscript.bom_tree.addNode(node, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
}
}
);
}
}
}
// First this function will execute and we will get list of operations
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':pscript.bom_no}, function(r,rt) {
var nl = r.message;
$i('bom_tree').innerHTML = '';
var t = new Tree($i('bom_tree'),$i('bom_head_op'),$i('bom_head_it'));
pscript.bom_tree = t;
pscript.bom_curnode = null;
for(var i=0; i<nl.length; i++) {
t.addNode(null, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
}
});
}
//
// Tree
//
function Tree(parent,head_op,head_it) {
this.container = parent;
this.heading = head_op;
this.nodes = {};
this.all_nodes = [];
var me = this;
this.body = $a(parent, 'div');
this.hopbody = $a(head_op, 'div');
this.hitbody = $a(head_it, 'div');
// columns
this.col_details = [
['340px','Opn No', 'Opn Descr','Item Code', 'Description',1,2]
,['150px','BOM' , 'BOM', 3]
,['80px', 'Workstn', 'Qty', 4]
,['45px', 'Hr Rate','Stock UOM',5]
,['45px', 'Time','Scrap',6]
,['50px', 'Mat Cost','Rate',7]
,['45px', 'Op Cost','',8]
,['50px', 'Tot Cost','',9]
,['25px', 'Refresh']
]
// Operation header
this.hopbody_tab = $a(this.hopbody, 'table');
$y(this.hopbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = this.hopbody_tab.insertRow(0);
for(var i=0; i<this.col_details.length; i++) {
var c = r0.insertCell(i);
c.style.width = this.col_details[i][0];
c.style.padding = '2px';
c.style.border = '1px solid #DDD';
if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][1];
}
this.hopbody_label = $a(r0.cells[0], 'div');
var hopbody_nodetab = $a(this.hopbody_label, 'table');
$y(hopbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = hopbody_nodetab.insertRow(0);
var c = r0.insertCell(0); c.style.width = '16px';
var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/wrench.png' />";
var c = r0.insertCell(2); c.style.width = '80px'; c.innerHTML = this.col_details[0][1];
l=340-116;
var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][2];
// Item Header
this.hitbody_tab = $a(this.hitbody, 'table');
$y(this.hitbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = this.hitbody_tab.insertRow(0);
for(var i=0; i<this.col_details.length; i++) {
var c = r0.insertCell(i);
c.style.width = this.col_details[i][0];
c.style.padding = '2px';
c.style.border = '1px solid #DDD';
if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][2];
}
this.hitbody_label = $a(r0.cells[0], 'div');
var hitbody_nodetab = $a(this.hitbody_label, 'table');
$y(hitbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = hitbody_nodetab.insertRow(0);
var c = r0.insertCell(0); c.style.width = '16px';
var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/package.png' />";
var c = r0.insertCell(2); c.style.width = '100px'; c.innerHTML = this.col_details[0][3];
l=350-136;
var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][4];
this.addNode = function(parent, head_op, label, imagesrc, onclick, onexpand) {
var t = new TreeNode(me, parent, head_op, label, imagesrc, onclick, onexpand);
if(!parent) {
me.nodes[label]=t; // add to roots
} else {
parent.nodes[label] = t; // add to the node
}
this.all_nodes.push(t);
// note: this will only be for groups
if(onexpand)t.create_expimage();
t.expanded_once = false;
return t;
}
this.deleteNode = function(node) {
node.container.remove(node);
}
var me = this;
this.collapseall = function() {
//alert("collapseall")
for(n in me.nodes) {
if (me.nodes[n].expimage){
l = me.nodes[n].get_list_of_child_nodes()
for (var i=0; i < l.length; i++ ) l[i].collapse(l[i]);
}
}
}
}
function TreeNode(tree, parent, head_op, label, imagesrc, onclick, onexpand) {
var me = this;
this.parent = parent;
this.head = head_op;
this.nodes = {};
this.onclick = onclick;
this.onexpand = onexpand;
this.text = label;
if(!parent) {
var container = tree.body;
}
else {
var container = parent.body;
}
var h_container = tree.hopbody;
var t = $a(container, "div");
var ht = $a(h_container, "div");
t.style.display = "none";
ht.style.display = "none";
this.node_area = $a(t, "div");
this.node_area.style.cursor = 'pointer';
this.loading_div = $a(container, "div");
this.loading_div.innerHTML = 'Loading...';
$dh(this.loading_div);
// main table
this.tab = $a(this.node_area, 'table');
$y(this.tab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = this.tab.insertRow(0);
for(var i=0; i<tree.col_details.length; i++) {
var c = r0.insertCell(i);
c.style.width = tree.col_details[i][0];
c.style.padding = '2px';
c.style.border = '1px solid #DDD';
}
this.label = $a(r0.cells[0], 'div');
var m=0;
var tn = this;
while(tn.parent){m+=16;tn=tn.parent;}
this.label.style.marginLeft = m+'px';
this.loading_div.style.marginLeft = m+40+'px';
var l = 350 - m;
this.body = $a(t, 'div'); // children will come here
// make the node
var nodetab = $a(this.label, 'table');
$y(nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
var r0 = nodetab.insertRow(0);
var c = r0.insertCell(0); c.style.width = '16px';
var c = r0.insertCell(1); c.style.width = '20px';
var c = r0.insertCell(2); c.style.width = '100px';
l=l-136;
var c = r0.insertCell(3); c.style.width = l+'px';
// BOM - is it item or operation
this.is_item = 1;
if(label[0] == 'operation') {
this.is_item = 0;
imagesrc = 'images/icons/wrench.png';
}
if(!imagesrc) imagesrc = "images/icons/folder.png";
this.usrimg = $a(nodetab.rows[0].cells[1], 'img');
this.usrimg.src = imagesrc;
//this.node_area.onmouseover = function() {this.style.backgroundColor = '#DEF'; }
//this.node_area.onmouseout = function() { this.style.backgroundColor = '#FFF'; }
this.create_expimage = function() {
if(!me.expimage) {
me.expimage = $a(nodetab.rows[0].cells[0], 'img');
me.expimage.style.marginTop = "3px";
me.expimage.src = "images/icons/plus.gif";
me.expimage.onclick = me.toggle;
me.expimage.node = me;
}
}
this.get_list_of_child_nodes = function() {
var main_l = [];
for (n in me.nodes){
if(!me.expimage){}
else{
var l = [];
if (me.nodes[n].get_list_of_child_nodes()) l = me.nodes[n].get_list_of_child_nodes();
for(var i=0 ; i < l.length; i ++){
main_l.push(l[i]);
}
alert(1);
main_l.push(me.nodes[n]);
alert(2);
}
}
return main_l
}
this.select = function() {
me.show_selected();
if(this.onclick)this.onclick(this);
}
this.show_selected = function() {
if(pscript.bom_curnode)pscript.bom_curnode.deselect();
me.tab.style.backgroundColor = '#DEF';
if(me.is_item == 1) tree.hitbody_tab.style.backgroundColor = '#DEF';
if(me.is_item == 0) tree.hopbody_tab.style.backgroundColor = '#DEF';
me.tab.style.fontWeight = 'bold';
pscript.bom_curnode = me;
$ds(me.refresh);
}
this.deselect = function() {
me.tab.style.fontWeight = 'normal';
pscript.bom_curnode=null;
me.tab.style.backgroundColor = '#FFF';
tree.hopbody_tab.style.backgroundColor = '#FFF';
tree.hitbody_tab.style.backgroundColor = '#FFF';
$dh(me.refresh);
}
var expanded = 1;
this.toggle = function(node) {
//alert("toggle")
if(!me.expimage)return;
if(me.expanded)me.collapse(this.node);
else me.expand(this.node);
}
this.collapse = function(node) {
//alert("collapse")
if(!node.expimage)return;
node.body.style.display = 'none';
if(node.expimage.src)node.expimage.src = "images/icons/plus.gif";
node.expanded = 0;
}
this.expand = function(node) {
//alert("expand")
if(!node.expimage)return;
if(node.onexpand)node.onexpand(node);
node.body.style.display = 'block';
if(node.expimage.src)node.expimage.src = "images/icons/minus.gif";
node.expanded = 1;
node.expanded_once = 1;
}
// BOM - Set values
for(var i=0;i<tree.col_details.length; i++) {
if ( i == 0) {
if(this.is_item == 1) {
var c = $a( nodetab.rows[0].cells[2], 'span', 'link_type');
c.item_code = label[tree.col_details[i][5]]
c.onclick = function() { loaddoc("Item", this.item_code); }
}
if(this.is_item == 0) var c = nodetab.rows[0].cells[2];
var d = nodetab.rows[0].cells[3];
c.innerHTML = label[tree.col_details[i][5]];
d.innerHTML = label[tree.col_details[i][6]].substring(0,15) + '...';
}
if(i==1) {
var c = $a(this.tab.rows[0].cells[i], 'div', 'link_type', {overflow:'hidden', width:'100%'});
c.bom_no = label[tree.col_details[i][3]]
c.onclick = function() { loaddoc("BOM", this.bom_no); }
c.innerHTML = label[tree.col_details[i][3]];
}
if(this.is_item == 1 && i > 1 && i < 6) {
var c = this.tab.rows[0].cells[i];
c.innerHTML = label[tree.col_details[i][3]];
}
if(this.is_item == 0 && i > 1 && tree.col_details[i][1] != 'Refresh') {
var c = this.tab.rows[0].cells[i];
c.innerHTML = label[tree.col_details[i][3]];
}
if(tree.col_details[i][1] == 'Refresh') {
this.refresh = $a(this.tab.rows[0].cells[i], 'span', 'link_type');
this.refresh.onclick = function() {
me.node = me
if(me.node.expanded_once){
me.node.body.innerHTML = '';
me.node.expanded_once = 0
me.expanded = 0
me.toggle();
}
else {me.toggle()}
}
this.refresh.innerHTML = "<img src='images/icons/page_refresh.gif' />"
$dh(this.refresh);
}
}
this.tab.onclick= function(e) { me.select(); }
this.tab.ondblclick = function(e) { me.select(); if(me.ondblclick)me.ondblclick(me); }
t.style.display = "block";
ht.style.display = "block";
}

View File

@ -1,58 +0,0 @@
# Page, Bill of Materials
[
# These values are common in all dictionaries
{
'creation': '2010-10-12 15:19:31',
'docstatus': 0,
'modified': '2010-12-23 12:58:19',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': 'Production',
'name': '__common__',
'page_name': 'Bill of Materials',
'show_in_menu': 1,
'standard': 'Yes'
},
# These values are common for all Page Role
{
'doctype': 'Page Role',
'name': '__common__',
'parent': 'Bill of Materials',
'parentfield': 'roles',
'parenttype': 'Page'
},
# Page, Bill of Materials
{
'doctype': 'Page',
'name': 'Bill of Materials'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 1,
'role': 'Administrator'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 2,
'role': 'Production User'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 3,
'role': 'Production Manager'
}
]

View File

@ -34,21 +34,6 @@
</div>
</div>
</div>
<div class="section">
<div class="section-head">Tools</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title = "browse bill of materials in a tree"
href="#!Bill of Materials">BOM Browser</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Update delivery dates in all Sales Orders"
href="#!Form/Update Delivery Date/Update Delivery Date">Update Delivery Dates</a>
</div>
</div>
</div>
</div>
</div>
<div style="clear: both;"></div>

View File

@ -83,10 +83,6 @@ def boot_session(bootinfo):
bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
import conf
bootinfo['sync_with_gateway'] = hasattr(conf, 'sync_with_gateway') and \
cint(conf.sync_with_gateway) or 0
def get_letter_heads():
"""load letter heads with startup"""
@ -117,4 +113,4 @@ def login_as(login_manager):
# throw execption
webnotes.msgprint("Authentication Failed", raise_exception=1)
return login_manager
return login_manager

View File

@ -43,11 +43,6 @@ erpnext.toolbar.setup = function() {
$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
Live Chat (Office Hours)</a></li>')
// billing
if(pscript.is_erpnext_saas && is_system_manager) {
$('#toolbar-user').append('<li><a href="#billing">Billing</a></li>')
}
$.extend(wn.container.wntoolbar, {
set_new_comments: function(new_comments) {
var navbar_nc = $('.navbar-new-comments');

View File

@ -38,9 +38,12 @@ erpnext.modules = {
'Dashboard': 'dashboard'
}
// wn.modules is used in breadcrumbs for getting module home page
wn.provide('wn.modules');
$.extend(wn.modules, erpnext.modules);
wn.modules['Core'] = 'Setup';
erpnext.startup.set_globals = function() {
wn.control_panel.sync_with_gateway = wn.boot.sync_with_gateway
pscript.is_erpnext_saas = cint(wn.control_panel.sync_with_gateway)
if(inList(user_roles,'System Manager')) is_system_manager = 1;
}

View File

@ -20,9 +20,12 @@ cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
console.log(doc.delivery_note);
var query = 'SELECT name, description FROM `tabItem` WHERE name IN ( \
SELECT item_code FROM `tabDelivery Note Item` dnd \
WHERE parent="' + doc.delivery_note + '" AND qty > packed_qty) AND %(key)s LIKE "%s" LIMIT 50';
WHERE parent="' + doc.delivery_note + '" AND IFNULL(qty, 0) > IFNULL(packed_qty, 0)) AND %(key)s LIKE "%s" LIMIT 50';
console.log(query);
return query;
}

View File

@ -1,30 +0,0 @@
# DocType, Question Control
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:02',
'docstatus': 0,
'modified': '2012-03-27 14:36:02',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'version': 1
},
# DocType, Question Control
{
'doctype': 'DocType',
'name': u'Question Control'
}
]

View File

@ -16,7 +16,7 @@
pscript['onload_question-view'] = function(wrapper) {
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
wrapper.appframe.title('<a href="#questions">Knowledge Base</a>');
wrapper.appframe.title('<span class="breadcrumbs"><a href="#questions">Knowledge Base</a></span>');
wrapper.add_answer_area = $('.add-answer-area').get(0);
}

View File

@ -22,6 +22,6 @@
# Page, questions
{
'doctype': 'Page',
'name': 'Questions'
'name': 'questions'
}
]

View File

@ -214,7 +214,7 @@ 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)
return true;}}})
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);})
/*
@ -251,7 +251,7 @@ throw new SyntaxError('JSON.parse');};}}());
wn.re_route={}
wn.route=function(){if(wn.re_route[window.location.hash]){window.location.hash=wn.re_route[window.location.hash];}
wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');}
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show(route[1],route[2]);break;default:wn.views.pageview.show(route[0]);}}
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}}
wn.get_route=function(route){if(!route)
route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return $.map(route.split('/'),function(r){return decodeURIComponent(r);});}
wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();}
@ -268,11 +268,11 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
\
<div class="list-filters hide">\
<div class="show_filters well">\
<div class="filter_area"></div>\
<div>\
<button class="btn btn-small add-filter-btn">\
<i class="icon-plus"></i> Add Filter</button>\
</div>\
<div class="filter_area"></div>\
</div>\
</div>\
\
@ -327,7 +327,7 @@ return this.filters[i];}}});wn.ui.Filter=Class.extend({init:function(opts){$.ext
<option value="=">Equals</option>\
<option value="like">Like</option>\
<option value=">=">Greater or equals</option>\
<option value=">=">Less or equals</option>\
<option value="<=">Less or equals</option>\
<option value=">">Greater than</option>\
<option value="<">Less than</option>\
<option value="in">In</option>\
@ -345,8 +345,9 @@ df.fieldtype=df.original_type;else
df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;}
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
if(cond=='like'){val=val+'%';}
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields){this.doctype=doctype;this.fields_by_name={};this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
/*
* lib/js/wn/views/container.js
@ -465,11 +466,27 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})
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='Report-'+dt;if(!wn.pages[page_name])
new wn.views.ReportView(dt);else
wn.container.change_to(page_name);}}
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype){var me=this;this.import_slickgrid();this.doctype=doctype;this.tab_name='`tab'+doctype+'`';this.columns=[['name'],['owner'],['creation'],['modified']];this.page=wn.container.add_page('Report-'+doctype);wn.model.with_doctype(doctype,function(){me.make_page();me.setup();me.make_column_picker();me.make_export();});},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(){wn.ui.make_app_page({parent:this.page,title:'Report - '+this.doctype,single_column:true});wn.container.change_to(this.page.label);},setup:function(){var me=this;this.make({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,show_grid:true,new_doctype:this.doctype,allow_delete:true,});this.run();},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return(v[1]?('`tab'+v[1]+'`'):me.tab_name)+'.'+v[0]}),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},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_export:function(){var me=this;if(wn.user.has_role(['Administrator','System Manager','Data Export'])){this.page.appframe.add_button('Export',function(){me.export();},'icon-download-alt');}},export:function(){var args=this.get_args();args.cmd='webnotes.widgets.doclistview.export_query'
open_url_post(wn.request.url,args)}});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'});}
wn.views.reportview2={show:function(dt){var route=wn.get_route();var page_name=window.location.hash.substr(1);if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{if(route[1]){new wn.views.ReportView(route[1],route[2]);}else{}}}}
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname){var me=this;this.page_name=window.location.hash.substr(1);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);var title='Report: '+this.doctype;if(this.docname)title+=' - '+this.docname;wn.ui.make_app_page({parent:this.page,title:title,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;this.make({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.message!=me.docname)
wn.set_route('Report2',me.doctype,me.docname);}});},'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>\
@ -510,7 +527,7 @@ wn.settings.no_history=1;var NEWLINE='\n';var profile=null;var user=null;var use
* lib/js/legacy/utils/datatype.js
*/
wn.utils.full_name=function(fn,ln){return fn+(ln?' ':'')+(ln?ln:'')}
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=wn.control_panel;var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var val=2;if(wn.boot.sysdefaults.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return'';}
var minus='';if(v<0){minus='-';}
i=Math.abs(i);var n=new String(i);var a=[];if(n.length>3)
@ -1419,7 +1436,7 @@ return false;}
* lib/js/wn/views/breadcrumbs.js
*/
wn.provide('wn.views');wn.views.breadcrumbs=function(parent,module,doctype,name){$(parent).empty();var $bspan=$(repl('<span class="breadcrumbs">\
<a href="#%(home_page)s">Home</a></span>',{home_page:wn.boot.home_page}));if(module){$bspan.append(repl(' / <a href="#!%(module_page)s">%(module)s Home</a>',{module:module,module_page:erpnext.modules[module]}))}
<a href="#%(home_page)s">Home</a></span>',{home_page:wn.boot.home_page}));if(module&&wn.modules[module]){$bspan.append(repl(' / <a href="#!%(module_page)s">%(module)s Home</a>',{module:module,module_page:wn.modules[module]}))}
if(doctype&&(locals.DocType[doctype]&&!locals.DocType[doctype].issingle)){$bspan.append(repl(' / <a href="#!List/%(doctype)s">%(doctype)s</a>',{doctype:doctype}))}
if(name){$bspan.append(' / '+name.bold())}
$bspan.appendTo(parent);}
@ -2196,7 +2213,7 @@ wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand'
* 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'}
erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
if(inList(user_roles,'System Manager'))is_system_manager=1;}
erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}

View File

@ -101,7 +101,7 @@ 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)
return true;}}})
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);})
/*
@ -138,7 +138,7 @@ throw new SyntaxError('JSON.parse');};}}());
wn.re_route={}
wn.route=function(){if(wn.re_route[window.location.hash]){window.location.hash=wn.re_route[window.location.hash];}
wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');}
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show(route[1],route[2]);break;default:wn.views.pageview.show(route[0]);}}
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}}
wn.get_route=function(route){if(!route)
route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return $.map(route.split('/'),function(r){return decodeURIComponent(r);});}
wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();}
@ -155,11 +155,11 @@ this.prepare_opts();$.extend(this,this.opts);$(this.parent).html(repl('\
\
<div class="list-filters hide">\
<div class="show_filters well">\
<div class="filter_area"></div>\
<div>\
<button class="btn btn-small add-filter-btn">\
<i class="icon-plus"></i> Add Filter</button>\
</div>\
<div class="filter_area"></div>\
</div>\
</div>\
\
@ -214,7 +214,7 @@ return this.filters[i];}}});wn.ui.Filter=Class.extend({init:function(opts){$.ext
<option value="=">Equals</option>\
<option value="like">Like</option>\
<option value=">=">Greater or equals</option>\
<option value=">=">Less or equals</option>\
<option value="<=">Less or equals</option>\
<option value=">">Greater than</option>\
<option value="<">Less than</option>\
<option value="in">In</option>\
@ -232,8 +232,9 @@ df.fieldtype=df.original_type;else
df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;}
if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
if(cond=='like'){val=val+'%';}
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields){this.doctype=doctype;this.fields_by_name={};this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype}];if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
$.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.fieldname]){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
/*
* lib/js/wn/views/container.js
@ -352,11 +353,27 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})
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='Report-'+dt;if(!wn.pages[page_name])
new wn.views.ReportView(dt);else
wn.container.change_to(page_name);}}
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype){var me=this;this.import_slickgrid();this.doctype=doctype;this.tab_name='`tab'+doctype+'`';this.columns=[['name'],['owner'],['creation'],['modified']];this.page=wn.container.add_page('Report-'+doctype);wn.model.with_doctype(doctype,function(){me.make_page();me.setup();me.make_column_picker();me.make_export();});},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(){wn.ui.make_app_page({parent:this.page,title:'Report - '+this.doctype,single_column:true});wn.container.change_to(this.page.label);},setup:function(){var me=this;this.make({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,show_grid:true,new_doctype:this.doctype,allow_delete:true,});this.run();},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return(v[1]?('`tab'+v[1]+'`'):me.tab_name)+'.'+v[0]}),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},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_export:function(){var me=this;if(wn.user.has_role(['Administrator','System Manager','Data Export'])){this.page.appframe.add_button('Export',function(){me.export();},'icon-download-alt');}},export:function(){var args=this.get_args();args.cmd='webnotes.widgets.doclistview.export_query'
open_url_post(wn.request.url,args)}});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'});}
wn.views.reportview2={show:function(dt){var route=wn.get_route();var page_name=window.location.hash.substr(1);if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{if(route[1]){new wn.views.ReportView(route[1],route[2]);}else{}}}}
wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname){var me=this;this.page_name=window.location.hash.substr(1);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);var title='Report: '+this.doctype;if(this.docname)title+=' - '+this.docname;wn.ui.make_app_page({parent:this.page,title:title,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;this.make({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.message!=me.docname)
wn.set_route('Report2',me.doctype,me.docname);}});},'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>\
@ -397,7 +414,7 @@ wn.settings.no_history=1;var NEWLINE='\n';var profile=null;var user=null;var use
* lib/js/legacy/utils/datatype.js
*/
wn.utils.full_name=function(fn,ln){return fn+(ln?' ':'')+(ln?ln:'')}
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=wn.control_panel;var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var val=2;if(wn.boot.sysdefaults.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return'';}
var minus='';if(v<0){minus='-';}
i=Math.abs(i);var n=new String(i);var a=[];if(n.length>3)
@ -805,7 +822,7 @@ wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand'
* 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'}
erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
if(inList(user_roles,'System Manager'))is_system_manager=1;}
erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}