blob: d46d49ec9e5718e45bd5b0547e315e9942b0c513 [file] [log] [blame]
Brahma Kd1a2cea2011-08-30 09:33:29 +05301if(user == 'Guest'){
2 $dh(page_body.left_sidebar);
3}
4
5var current_module;
6var is_system_manager = 0;
7var module_content_dict = {};
8var user_full_nm = {};
9
10// check if session user is system manager
11if(inList(user_roles,'System Manager')) is_system_manager = 1;
12
13function startup_setup() {
14 pscript.is_erpnext_saas = cint(locals['Control Panel']['Control Panel'].sync_with_gateway)
15
Brahma Kd1a2cea2011-08-30 09:33:29 +053016 if(get_url_arg('embed')) {
17 // hide header, footer
18 $dh(page_body.banner_area);
19 $dh(page_body.wntoolbar);
20 $dh(page_body.footer);
21 return;
22 }
Brahma Kd1a2cea2011-08-30 09:33:29 +053023 // page structure
24 // --------------
Rushabh Mehtabedc1fe2012-01-17 18:17:06 +053025 if(page_body.wntoolbar) {
26 $td(page_body.wntoolbar.body_tab,0,0).innerHTML = '<i><b>erp</b>next</i>';
27 $y($td(page_body.wntoolbar.body_tab,0,0), {
28 width:'140px',
29 color:'#FFF',
30 paddingLeft:'8px',
31 paddingRight:'8px',
32 fontSize:'14px'
33 });
34 }
Brahma Kd1a2cea2011-08-30 09:33:29 +053035 $dh(page_body.banner_area);
36
37 // sidebar
38 // -------
39 pscript.startup_make_sidebar();
40
41 // border to the body
42 // ------------------
Rushabh Mehtabedc1fe2012-01-17 18:17:06 +053043 page_body.footer.innerHTML = '<div class="erpnext-footer">Powered by <a href="https://erpnext.com">ERPNext</a></div>';
Brahma Kd1a2cea2011-08-30 09:33:29 +053044
Rushabh Mehta5f66d602011-10-11 10:58:11 +053045 // setup toolbar
46 pscript.startup_setup_toolbar();
Brahma Kd1a2cea2011-08-30 09:33:29 +053047}
48
49// ====================================================================
50
51pscript.startup_make_sidebar = function() {
52 $y(page_body.left_sidebar, {width:(100/6)+'%', paddingTop:'8px'});
53
54 var callback = function(r,rt) {
55 // menu
56 var ml = r.message;
57
58 // clear
59 page_body.left_sidebar.innerHTML = '';
60
61 for(var m=0; m<ml.length; m++){
62 if(ml[m]) {
63 new SidebarItem(ml[m]);
64 }
65 }
66 if(in_list(user_roles, 'System Manager')) {
67 var div = $a(page_body.left_sidebar, 'div', 'link_type', {padding:'8px', fontSize:'11px'});
68 $(div).html('[edit]').click(pscript.startup_set_module_order)
69 }
70 nav_obj.observers.push({notify:function(t,dt,dn) { pscript.select_sidebar_menu(t, dt, dn); }});
71
72 // select current
73 var no = nav_obj.ol[nav_obj.ol.length-1];
74 if(no && menu_item_map[decodeURIComponent(no[0])][decodeURIComponent(no[1])])
75 pscript.select_sidebar_menu(decodeURIComponent(no[0]), decodeURIComponent(no[1]));
76 }
77 $c_obj('Home Control', 'get_modules', '', callback);
78}
79
80// ====================================================================
81// Menu observer
82// ====================================================================
83
84cur_menu_pointer = null;
85var menu_item_map = {'Form':{}, 'Page':{}, 'Report':{}, 'List':{}}
86
87pscript.select_sidebar_menu = function(t, dt, dn) {
88 // get menu item
89 if(menu_item_map[t][dt]) {
90 // select
91 menu_item_map[t][dt].select();
92 } else {
93 // none found :-( Unselect
94 if(cur_menu_pointer)
95 cur_menu_pointer.deselect();
96 }
97}
98
99// ====================================================================
100// Menu pointer
101// ====================================================================
102
103var body_background = '#e2e2e2';
104
105MenuPointer = function(parent, label) {
106
107 this.wrapper = $a(parent, 'div', '', {padding:'0px', cursor:'pointer', margin:'2px 0px'});
108 $br(this.wrapper, '3px');
109
110 this.tab = make_table($a(this.wrapper, 'div'), 1, 2, '100%', ['', '11px'], {height:'22px',
111 verticalAlign:'middle', padding:'0px'}, {borderCollapse:'collapse', tableLayout:'fixed'});
112
113 $y($td(this.tab, 0, 0), {padding:'0px 4px', color:'#444', whiteSpace:'nowrap'});
114
115 // triangle border (?)
116 this.tab.triangle_div = $a($td(this.tab, 0, 1), 'div','', {
Nabin Haitb30c4a62011-10-05 11:36:16 +0530117 borderColor: body_background + ' ' + body_background + ' ' + body_background + ' ' + 'transparent',
Brahma Kd1a2cea2011-08-30 09:33:29 +0530118 borderWidth:'11px', borderStyle:'solid', height:'0px', width:'0px', marginRight:'-11px'});
119
120 this.label_area = $a($td(this.tab, 0, 0), 'span', '', '', label);
121
122 $(this.wrapper)
123 .hover(
Nabin Haitb30c4a62011-10-05 11:36:16 +0530124 function() { if(!this.selected)$bg(this, '#eee'); } ,
125 function() { if(!this.selected)$bg(this, body_background); }
Brahma Kd1a2cea2011-08-30 09:33:29 +0530126 )
127
128 $y($td(this.tab, 0, 0), {borderBottom:'1px solid #ddd'});
129
130}
131
132// ====================================================================
133
134MenuPointer.prototype.select = function(grey) {
Nabin Haitb30c4a62011-10-05 11:36:16 +0530135 $y($td(this.tab, 0, 0), {color:'#fff', borderBottom:'0px solid #000'});
Brahma Kd1a2cea2011-08-30 09:33:29 +0530136 //$gr(this.wrapper, '#F84', '#F63');
137 $gr(this.wrapper, '#888', '#666');
138 this.selected = 1;
139
140 if(cur_menu_pointer && cur_menu_pointer != this)
141 cur_menu_pointer.deselect();
142
143 cur_menu_pointer = this;
144}
145
146// ====================================================================
147
148MenuPointer.prototype.deselect = function() {
Nabin Haitb30c4a62011-10-05 11:36:16 +0530149 $y($td(this.tab, 0, 0), {color:'#444', borderBottom:'1px solid #ddd'});
Brahma Kd1a2cea2011-08-30 09:33:29 +0530150 $gr(this.wrapper, body_background, body_background);
151 this.selected = 0;
152}
153
154
155// ====================================================================
156// Sidebar Item
157// ====================================================================
158
159var cur_sidebar_item = null;
160
161SidebarItem = function(det) {
162 var me = this;
163 this.det = det;
164 this.wrapper = $a(page_body.left_sidebar, 'div', '', {marginRight:'12px'});
165
166 this.body = $a(this.wrapper, 'div');
167 this.tab = make_table(this.body, 1, 2, '100%', ['24px', null], {verticalAlign:'middle'}, {tableLayout:'fixed'});
168
169 // icon
170 var ic = $a($td(this.tab, 0, 0), 'div', 'module-icons module-icons-' + det.module_label.toLowerCase(), {marginLeft:'3px', marginBottom:'-2px'});
171
172 // pointer table
173 this.pointer = new MenuPointer($td(this.tab, 0, 1), det.module_label);
174 $y($td(this.pointer.tab, 0, 0), {fontWeight:'bold'});
175
176 // for page type
177 if(det.module_page) {
178 menu_item_map.Page[det.module_page] = this.pointer;
179 }
180
181 // items area
182 this.items_area = $a(this.wrapper, 'div');
183
184 this.body.onclick = function() { me.onclick(); }
185}
186
187// ====================================================================
188
189SidebarItem.prototype.onclick = function() {
190 var me = this;
191
192 if(this.det.module_page) {
193 // page type
194 this.pointer.select();
195
196 $item_set_working(me.pointer.label_area);
197 loadpage(this.det.module_page, function() { $item_done_working(me.pointer.label_area); });
198
199 } else {
200 // show sub items
201 this.toggle();
202 }
203}
204
205// ====================================================================
206
207SidebarItem.prototype.collapse = function() {
208 $(this.items_area).slideUp();
209 this.is_open = 0;
210 $fg(this.pointer.label_area, '#444')
211}
212
213// ====================================================================
214
215SidebarItem.prototype.toggle = function() {
216 if(this.loading) return;
217
218 if(this.is_open) {
219 this.collapse();
220 } else {
221 if(this.loaded) $(this.items_area).slideDown();
222 else this.show_items();
223 this.is_open = 1;
224 $fg(this.pointer.label_area, '#000')
225 //this.pointer.select(1);
226
227 // close existing open
228 if(cur_sidebar_item && cur_sidebar_item != this) {
229 cur_sidebar_item.collapse();
230 }
231 cur_sidebar_item = this;
232 }
233}
234
235// ====================================================================
236
237SidebarItem.prototype.show_items = function() {
238 this.loading = 1;
239 var me = this;
240
241 $item_set_working(this.pointer.label_area);
242 var callback = function(r,rt){
243 me.loaded = 1;
244 me.loading = 0;
245 var smi = null;
246 var has_reports = 0;
247 var has_tools = 0;
248
249 // widget code
250 $item_done_working(me.pointer.label_area);
251
252 if(r.message.il) {
253 me.il = r.message.il;
254
255 // forms
256 for(var i=0; i<me.il.length;i++){
257 if(me.il[i].doc_type == 'Forms') {
258 if(in_list(profile.can_read, me.il[i].doc_name)) {
259 var smi = new SidebarModuleItem(me, me.il[i]);
260
261 menu_item_map['Form'][me.il[i].doc_name] = smi.pointer;
262 menu_item_map['List'][me.il[i].doc_name] = smi.pointer;
263 }
264 }
265 if(me.il[i].doc_type=='Reports') has_reports = 1;
266 if(in_list(['Single DocType', 'Pages', 'Setup Forms'], me.il[i].doc_type)) has_tools = 1;
267 }
268 // reports
269 if(has_reports) {
270 var smi = new SidebarModuleItem(me, {doc_name:'Reports', doc_type:'Reports'});
271
272 // add to menu-item mapper
273 menu_item_map['Page'][me.det.module_label + ' Reports'] = smi.pointer;
274 }
275
276 // tools
277 if(has_tools) {
278 var smi = new SidebarModuleItem(me, {doc_name:'Tools', doc_type:'Tools'});
279
280 // add to menu-item mapper
281 menu_item_map['Page'][me.det.module_label + ' Tools'] = smi.pointer;
282 }
283
284 // custom reports
285 if(r.message.custom_reports.length) {
286 me.il = add_lists(r.message.il, r.message.custom_reports);
287 var smi = new SidebarModuleItem(me, {doc_name:'Custom Reports', doc_type:'Custom Reports'});
288
289 // add to menu-item mapper
290 menu_item_map['Page'][me.det.module_label + ' Custom Reports'] = smi.pointer;
Brahma Kd1a2cea2011-08-30 09:33:29 +0530291 }
Brahma Kd1a2cea2011-08-30 09:33:29 +0530292 }
Rushabh Mehta5f66d602011-10-11 10:58:11 +0530293
Rushabh Mehta5f66d602011-10-11 10:58:11 +0530294
Brahma Kd1a2cea2011-08-30 09:33:29 +0530295 $(me.items_area).slideDown();
296
297 // high light
298 var no = nav_obj.ol[nav_obj.ol.length-1];
299 if(no && menu_item_map[decodeURIComponent(no[0])][decodeURIComponent(no[1])])
300 pscript.select_sidebar_menu(decodeURIComponent(no[0]), decodeURIComponent(no[1]));
301
302 }
303
304 $c_obj('Home Control', 'get_module_details', me.det.name, callback);
305}
306
307// ====================================================================
308// Show Reports
309// ====================================================================
310
311SidebarItem.prototype.show_section = function(sec_type) {
312 var me = this;
313 var label = this.det.module_label + ' ' + sec_type;
314 var type_map = {'Reports':'Reports', 'Custom Reports':'Custom Reports', 'Pages':'Tools', 'Single DocType':'Tools', 'Setup Forms':'Tools'}
315
316 if(page_body.pages[label]) {
317 loadpage(label, null, 1);
318 } else {
319 // make the reports page
320 var page = page_body.add_page(label);
321 this.wrapper = $a(page,'div','layout_wrapper');
322
323
324 // head
325 this.head = new PageHeader(this.wrapper, label);
326
327 // body
328 this.body1 = $a(this.wrapper, 'div', '', {marginTop:'16px'});
329
330 // add a report link
331 var add_link = function(det) {
332 var div = $a(me.body1, 'div', '', {marginBottom:'6px'});
333 var span = $a(div, 'span', 'link_type');
334
335 // tag the span
336 span.innerHTML = det.display_name; span.det = det;
337 if(sec_type=='Reports' || sec_type=='Custom Reports') {
338 // Reports
339 // -------
340 span.onclick = function() { loadreport(this.det.doc_name, this.det.display_name); }
341
342 } else {
343 // Tools
344 // -----
345
346 if(det.doc_type=='Pages') {
347 // Page
348 if(det.click_function) {
349 span.onclick = function() { eval(this.det.click_function) }
350 span.click_function = det.click_function;
351 } else {
352 span.onclick = function() { loadpage(this.det.doc_name); }
353 }
354 } else if(det.doc_type=='Setup Forms') {
355 // Doc Browser
356 span.onclick = function() { loaddocbrowser(this.det.doc_name); }
357 } else {
358 // Single
359 span.onclick = function() { loaddoc(this.det.doc_name, this.det.doc_name); }
360 }
361 }
362 }
363
364 // item list
365 for(var i=0; i<me.il.length;i++){
366 if(type_map[me.il[i].doc_type] == sec_type) {
367 add_link(me.il[i]);
368 }
369 }
370 loadpage(label, null, 1);
371 }
372}
373
374
375// ====================================================================
376// Sidebar module item
377// ====================================================================
378
379SidebarModuleItem = function(si, det) {
380 this.det = det;
381 var me= this;
382
383 this.pointer = new MenuPointer(si.items_area, get_doctype_label(det.doc_name));
384 $y(si.items_area, {marginLeft:'32px'})
385 $y($td(this.pointer.tab, 0, 0), {fontSize:'11px'});
386
387 this.pointer.wrapper.onclick = function() {
388 if(me.det.doc_type=='Forms')
389 loaddocbrowser(det.doc_name);
390 else
391 si.show_section(me.det.doc_type);
392 }
393}
394
395
396// ====================================================================
397// Drag & Drop order selection
398// ====================================================================
399
400pscript.startup_set_module_order = function() {
401 var update_order= function(ml) {
402 mdict = {};
403 for(var i=0; i<ml.length; i++) {
404 mdict[ml[i][3][3]] = {'module_seq':ml[i][1], 'is_hidden':(ml[i][2] ? 'No' : 'Yes')}
405 }
406 $c_obj('Home Control', 'set_module_order', JSON.stringify(mdict), function(r,rt) { pscript.startup_make_sidebar(); } )
407 }
408
409 var callback = function(r, rt) {
410 var ml = [];
411 for(var i=0; i<r.message.length; i++) {
412 var det = r.message[i];
413 ml.push([det[1], det[2], (det[3]!='No' ? 0 : 1), det[0]]);
414 }
415 new ListSelector('Set Module Sequence', 'Select items and set the order you want them to appear'+
416 '<br><b>Note:</b> <i>These changes will apply to all users!</i>', ml, update_order, 1);
417 }
418 $c_obj('Home Control', 'get_module_order', '', callback)
419
420}
421
422// ====================================================================
423
424pscript.startup_setup_toolbar = function() {
425 var menu_tab = page_body.wntoolbar.menu_table_right;
Anand Doshia31fd102012-01-06 16:27:54 +0530426 // help
427 // ----
428 $td(menu_tab,0,0).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://erpnext.blogspot.com/2011/03/erpnext-help.html" target="_blank">Help</a>';
429
430 $td(menu_tab,0,1).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://groups.google.com/group/erpnext-user-forum" target="_blank">Forum</a>';
431
Brahma Kd1a2cea2011-08-30 09:33:29 +0530432 if(pscript.is_erpnext_saas){
Anand Doshia31fd102012-01-06 16:27:54 +0530433 // Live Chat Help
434 // --------------
435 $td(menu_tab,0,2).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">Chat</a>';
436
Brahma Kd1a2cea2011-08-30 09:33:29 +0530437 // Manage account
438 // --------------
439 if(is_system_manager) {
440 $td(menu_tab,0,3).innerHTML = '<a style="font-weight: bold; color: #FFF;" href="#!billing">Billing</a>';
441 }
442 }
443 else{
Anand Doshia31fd102012-01-06 16:27:54 +0530444 $dh($td(menu_tab,0,2));
Brahma Kd1a2cea2011-08-30 09:33:29 +0530445 $dh($td(menu_tab,0,3));
446 }
447
Brahma Kd1a2cea2011-08-30 09:33:29 +0530448 $y(cell, page_body.wntoolbar.right_table_style);
449
450}
451
452// chart of accounts
453// ====================================================================
454show_chart_browser = function(nm, chart_type){
455
456 var call_back = function(){
457 if(nm == 'Sales Browser'){
458 var sb_obj = new SalesBrowser();
459 sb_obj.set_val(chart_type);
460 }
461 else if(nm == 'Accounts Browser')
462 pscript.make_chart(chart_type);
463 }
464 loadpage(nm,call_back);
465}
466
467
468// Module Page
469// ====================================================================
470
471ModulePage = function(parent, module_name, module_label, help_page, callback) {
472 this.parent = parent;
473
474 // add to current page
475 page_body.cur_page.module_page = this;
476
477 this.wrapper = $a(parent,'div');
478 this.module_name = module_name;
479 this.transactions = [];
480 this.page_head = new PageHeader(this.wrapper, module_label);
481
482 if(help_page) {
483 var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help')
484 btn.help_page = help_page;
485 }
486
487 if(callback) this.callback = function(){ callback(); }
488}
489
490
491// get plural
492// ====================================================================
493
494get_plural = function(str){
495 if(str.charAt(str.length-1).toLowerCase() == 'y') return str.substr(0, str.length-1) + 'ies'
496 else return str + 's';
497}
498
499// set user fullname
500// ====================================================================
501pscript.set_user_fullname = function(ele,username,get_latest){
502
503 var set_it = function(){
504 if(ele)
505 ele.innerHTML = user_full_nm[username];
506 }
507
508 if(get_latest){
509 $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); });
510 }
511 else{
512 if(user_full_nm[username]){
513 set_it();
514 }
515
516 else
517 $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); });
518 }
519}
520
521// ====================================================================
522startup_setup();
523
524/* features setup "Dictionary", "Script"
525Dictionary Format
526 'projects': {
527 'Sales Order': {
528 'fields':['project_name'],
529 'sales_order_details':['projected_qty']
530 },
531 'Purchase Order': {
532 'fields':['project_name']
533 }
534 }
535// ====================================================================*/
536pscript.feature_dict = {
Nabin Haitb30c4a62011-10-05 11:36:16 +0530537 'fs_projects': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530538 'Bill Of Materials': {'fields':['project_name']},
539 'Delivery Note': {'fields':['project_name']},
540 'Payable Voucher': {'fields':['project_name']},
541 'Production Order': {'fields':['project_name']},
542 'Purchase Order': {'fields':['project_name']},
543 'Purchase Receipt': {'fields':['project_name']},
544 'Receivable Voucher': {'fields':['project_name']},
545 'Sales Order': {'fields':['project_name']},
546 'Stock Entry': {'fields':['project_name']},
547 'Timesheet': {'timesheet_details':['project_name']}
548 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530549 'fs_packing_details': {
Nabin Haitc1d42812011-10-11 12:50:55 +0530550 'Delivery Note': {'fields':['packing_details','print_packing_slip','packing_checked_by','packed_by','pack_size','shipping_mark'],'delivery_note_details':['no_of_packs','pack_gross_wt','pack_nett_wt','pack_no','pack_unit']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530551 'Sales Order': {'fields':['packing_details']}
552 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530553 'fs_discounts': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530554 'Delivery Note': {'delivery_note_details':['adj_rate']},
555 'Quotation': {'quotation_details':['adj_rate']},
Brahma K5ecb6932011-08-31 09:02:01 +0530556 'Receivable Voucher': {'entries':['adj_rate']},
Brahma K3c9a6a12011-08-31 12:55:41 +0530557 'Sales Order': {'sales_order_details':['adj_rate','ref_rate']}
Brahma Kd1a2cea2011-08-30 09:33:29 +0530558 },
Nabin Hait3a2fcba2011-12-14 11:26:46 +0530559 'fs_purchase_discounts': {
560 'Purchase Order': {'po_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
561 'Purchase Receipt': {'purchase_receipt_details':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']},
562 'Payable Voucher': {'entries':['purchase_ref_rate', 'discount_rate', 'import_ref_rate']}
563 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530564 'fs_brands': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530565 'Delivery Note': {'delivery_note_details':['brand']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530566 'Indent': {'indent_details':['brand']},
567 'Item': {'fields':['brand']},
568 'Purchase Order': {'po_details':['brand']},
Brahma K5ecb6932011-08-31 09:02:01 +0530569 'Payable Voucher': {'entries':['brand']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530570 'Quotation': {'quotation_details':['brand']},
Brahma K5ecb6932011-08-31 09:02:01 +0530571 'Receivable Voucher': {'entries':['brand']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530572 'Sales BOM': {'fields':['new_item_brand']},
573 'Sales Order': {'sales_order_details':['brand']},
574 'Serial No': {'fields':['brand']}
575 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530576 'fs_after_sales_installations': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530577 'Delivery Note': {'fields':['installation_status','per_installed'],'delivery_note_details':['installed_qty']}
578 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530579 'fs_item_batch_nos': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530580 'Delivery Note': {'delivery_note_details':['batch_no']},
581 'Item': {'fields':['has_batch_no']},
582 'Purchase Receipt': {'purchase_receipt_details':['batch_no']},
583 'QA Inspection Report': {'fields':['batch_no']},
584 'Sales and Pruchase Return Wizard': {'return_details':['batch_no']},
Brahma K5ecb6932011-08-31 09:02:01 +0530585 'Receivable Voucher': {'entries':['batch_no']},
586 'Stock Entry': {'mtn_details':['batch_no']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530587 'Stock Ledger Entry': {'fields':['batch_no']}
588 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530589 'fs_item_serial_nos': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530590 'Customer Issue': {'fields':['serial_no']},
Brahma K5ecb6932011-08-31 09:02:01 +0530591 'Delivery Note': {'delivery_note_details':['serial_no'],'packing_details':['serial_no']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530592 'Installation Note': {'installed_item_details':['serial_no']},
593 'Item': {'fields':['has_serial_no']},
594 'Maintenance Schedule': {'item_maintenance_details':['serial_no'],'maintenance_schedule_details':['serial_no']},
595 'Maintenance Visit': {'maintenance_visit_details':['serial_no']},
596 'Purchase Receipt': {'purchase_receipt_details':['serial_no']},
597 'QA Inspection Report': {'fields':['item_serial_no']},
598 'Sales and Pruchase Return Wizard': {'return_details':['serial_no']},
Brahma K5ecb6932011-08-31 09:02:01 +0530599 'Receivable Voucher': {'entries':['serial_no']},
600 'Stock Entry': {'mtn_details':['serial_no']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530601 'Stock Ledger Entry': {'fields':['serial_no']}
602 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530603 'fs_item_group_in_details': {
Brahma Kd1a2cea2011-08-30 09:33:29 +0530604 'Delivery Note': {'delivery_note_details':['item_group']},
605 'Enquiry': {'enquiry_details':['item_group']},
606 'Indent': {'indent_details':['item_group']},
607 'Item': {'fields':['item_group']},
608 'Manage Account': {'fields':['default_item_group']},
609 'Purchase Order': {'po_details':['item_group']},
610 'Purchase Receipt': {'purchase_receipt_details':['item_group']},
Brahma K5ecb6932011-08-31 09:02:01 +0530611 'Purchase Voucher': {'entries':['item_group']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530612 'Quotation': {'quotation_details':['item_group']},
Brahma K5ecb6932011-08-31 09:02:01 +0530613 'Receivable Voucher': {'entries':['item_group']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530614 'Sales BOM': {'fields':['serial_no']},
615 'Sales Order': {'sales_order_details':['item_group']},
616 'Serial No': {'fields':['item_group']},
617 'Sales Partner': {'partner_target_details':['item_group']},
618 'Sales Person': {'target_details':['item_group']},
619 'Territory': {'target_details':['item_group']}
620 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530621 'fs_page_break': {
Brahma K5ecb6932011-08-31 09:02:01 +0530622 'Delivery Note': {'delivery_note_details':['page_break'],'packing_details':['page_break']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530623 'Indent': {'indent_details':['page_break']},
624 'Purchase Order': {'po_details':['page_break']},
625 'Purchase Receipt': {'purchase_receipt_details':['page_break']},
Brahma K5ecb6932011-08-31 09:02:01 +0530626 'Purchase Voucher': {'entries':['page_break']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530627 'Quotation': {'quotation_details':['page_break']},
Brahma K5ecb6932011-08-31 09:02:01 +0530628 'Receivable Voucher': {'entries':['page_break']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530629 'Sales Order': {'sales_order_details':['page_break']}
630 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530631 'fs_exports': {
Brahma K5ecb6932011-08-31 09:02:01 +0530632 'Delivery Note': {'fields':['Note','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['base_ref_rate','export_amount','export_rate']},
633 'POS Setting': {'fields':['conversion_rate','currency']},
634 'Quotation': {'fields':['Note HTML','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'quotation_details':['base_ref_rate','export_amount','export_rate']},
635 'Receivable Voucher': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['base_ref_rate','export_amount','export_rate']},
636 'Item': {'ref_rate_details':['ref_currency']},
Brahma Kd1a2cea2011-08-30 09:33:29 +0530637 'Sales BOM': {'fields':['currency']},
Brahma K8e8c4822011-08-31 15:46:29 +0530638 'Sales Order': {'fields':['Note1','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'sales_order_details':['base_ref_rate','export_amount','export_rate']}
Brahma Kd1a2cea2011-08-30 09:33:29 +0530639 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530640 'fs_imports': {
Brahma K5ecb6932011-08-31 09:02:01 +0530641 'Payable Voucher': {'fields':['conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'entries':['import_amount','import_rate']},
642 'Purchase Order': {'fields':['Note HTML','conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'po_details':['import_amount','import_rate']},
Brahma K8e8c4822011-08-31 15:46:29 +0530643 'Purchase Receipt': {'fields':['conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'purchase_receipt_details':['import_amount','import_rate']},
644 'Supplier Quotation': {'fields':['conversion_rate','currency']}
Brahma K5ecb6932011-08-31 09:02:01 +0530645 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530646 'fs_item_advanced': {
Brahma K5ecb6932011-08-31 09:02:01 +0530647 'Item': {'fields':['item_customer_details']}
648 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530649 'fs_sales_extras': {
Brahma K5ecb6932011-08-31 09:02:01 +0530650 'Address': {'fields':['sales_partner']},
651 'Contact': {'fields':['sales_partner']},
652 'Customer': {'fields':['sales_team']},
653 'Delivery Note': {'fields':['sales_team','Packing List']},
654 'Item': {'fields':['item_customer_details']},
655 'Receivable Voucher': {'fields':['sales_team']},
656 'Sales Order': {'fields':['sales_team','Packing List']}
657 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530658 'fs_more_info': {
Brahma K5ecb6932011-08-31 09:02:01 +0530659 'Customer': {'fields':['More Info']},
660 'Delivery Note': {'fields':['More Info']},
661 'Enquiry': {'fields':['More Info']},
662 'Indent': {'fields':['More Info']},
663 'Lead': {'fields':['More Info']},
664 'Payable Voucher': {'fields':['More Info']},
665 'Purchase Order': {'fields':['More Info']},
666 'Purchase Receipt': {'fields':['More Info']},
667 'Quotation': {'fields':['More Info']},
668 'Receivable Voucher': {'fields':['More Info']},
669 'Sales Order': {'fields':['More Info']},
670 'Serial No': {'fields':['More Info']},
671 'Supplier': {'fields':['More Info']}
672 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530673 'fs_quality': {
Brahma K5ecb6932011-08-31 09:02:01 +0530674 'Item': {'fields':['Item Inspection Criteria','inspection_required']},
675 'Purchase Receipt': {'purchase_receipt_details':['qa_no']}
676 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530677 'fs_manufacturing': {
Brahma K5ecb6932011-08-31 09:02:01 +0530678 'Item': {'fields':['Manufacturing']}
679 },
Nabin Haitb30c4a62011-10-05 11:36:16 +0530680 'fs_pos': {
Brahma K5ecb6932011-08-31 09:02:01 +0530681 'Receivable Voucher': {'fields':['is_pos']}
Nabin Hait38d24532011-12-06 19:04:21 +0530682 },
683 'fs_recurring_invoice': {
684 'Receivable Voucher': {'fields': ['Recurring Invoice']}
Brahma Kd1a2cea2011-08-30 09:33:29 +0530685 }
Brahma Kd1a2cea2011-08-30 09:33:29 +0530686}
687
688$(document).bind('form_refresh', function() {
689 for(sys_feat in sys_defaults)
690 {
691 if(sys_defaults[sys_feat]=='0' && (sys_feat in pscript.feature_dict)) //"Features to hide" exists
692 {
693 if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat])
694 {
695 for(fort in pscript.feature_dict[sys_feat][cur_frm.doc.doctype])
696 {
697 if(fort=='fields')
698 hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]);
Brahma K5ecb6932011-08-31 09:02:01 +0530699 else if(cur_frm.fields_dict[fort])
Brahma Kd1a2cea2011-08-30 09:33:29 +0530700 {
701 for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort])
Brahma K5ecb6932011-08-31 09:02:01 +0530702 cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false);
Brahma Kd1a2cea2011-08-30 09:33:29 +0530703 }
Brahma K5ecb6932011-08-31 09:02:01 +0530704 else
705 msgprint('Grid "'+fort+'" does not exists');
Brahma Kd1a2cea2011-08-30 09:33:29 +0530706 }
707 }
708 }
709 }
710})