Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 1 | if(user == 'Guest'){ |
| 2 | $dh(page_body.left_sidebar); |
| 3 | } |
| 4 | |
| 5 | var current_module; |
| 6 | var is_system_manager = 0; |
| 7 | var module_content_dict = {}; |
| 8 | var user_full_nm = {}; |
| 9 | |
| 10 | // check if session user is system manager |
| 11 | if(inList(user_roles,'System Manager')) is_system_manager = 1; |
| 12 | |
| 13 | function startup_setup() { |
| 14 | pscript.is_erpnext_saas = cint(locals['Control Panel']['Control Panel'].sync_with_gateway) |
| 15 | |
| 16 | |
| 17 | if(get_url_arg('embed')) { |
| 18 | // hide header, footer |
| 19 | $dh(page_body.banner_area); |
| 20 | $dh(page_body.wntoolbar); |
| 21 | $dh(page_body.footer); |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | if(user=='Guest' && !get_url_arg('akey')) { |
| 26 | if(pscript.is_erpnext_saas) { |
| 27 | window.location.href = 'https://www.erpnext.com'; |
| 28 | return; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // page structure |
| 33 | // -------------- |
| 34 | $td(page_body.wntoolbar.body_tab,0,0).innerHTML = '<i><b>erp</b>next</i>'; |
| 35 | $y($td(page_body.wntoolbar.body_tab,0,0), {width:'140px', color:'#FFF', paddingLeft:'8px', paddingRight:'8px', fontSize:'14px'}) |
| 36 | $dh(page_body.banner_area); |
| 37 | |
| 38 | // sidebar |
| 39 | // ------- |
| 40 | pscript.startup_make_sidebar(); |
| 41 | |
| 42 | // border to the body |
| 43 | // ------------------ |
| 44 | $dh(page_body.footer); |
| 45 | |
Rushabh Mehta | 5f66d60 | 2011-10-11 10:58:11 +0530 | [diff] [blame] | 46 | // setup toolbar |
| 47 | pscript.startup_setup_toolbar(); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | // ==================================================================== |
| 51 | |
| 52 | pscript.startup_make_sidebar = function() { |
| 53 | $y(page_body.left_sidebar, {width:(100/6)+'%', paddingTop:'8px'}); |
| 54 | |
| 55 | var callback = function(r,rt) { |
| 56 | // menu |
| 57 | var ml = r.message; |
| 58 | |
| 59 | // clear |
| 60 | page_body.left_sidebar.innerHTML = ''; |
| 61 | |
| 62 | for(var m=0; m<ml.length; m++){ |
| 63 | if(ml[m]) { |
| 64 | new SidebarItem(ml[m]); |
| 65 | } |
| 66 | } |
| 67 | if(in_list(user_roles, 'System Manager')) { |
| 68 | var div = $a(page_body.left_sidebar, 'div', 'link_type', {padding:'8px', fontSize:'11px'}); |
| 69 | $(div).html('[edit]').click(pscript.startup_set_module_order) |
| 70 | } |
| 71 | nav_obj.observers.push({notify:function(t,dt,dn) { pscript.select_sidebar_menu(t, dt, dn); }}); |
| 72 | |
| 73 | // select current |
| 74 | var no = nav_obj.ol[nav_obj.ol.length-1]; |
| 75 | if(no && menu_item_map[decodeURIComponent(no[0])][decodeURIComponent(no[1])]) |
| 76 | pscript.select_sidebar_menu(decodeURIComponent(no[0]), decodeURIComponent(no[1])); |
| 77 | } |
| 78 | $c_obj('Home Control', 'get_modules', '', callback); |
| 79 | } |
| 80 | |
| 81 | // ==================================================================== |
| 82 | // Menu observer |
| 83 | // ==================================================================== |
| 84 | |
| 85 | cur_menu_pointer = null; |
| 86 | var menu_item_map = {'Form':{}, 'Page':{}, 'Report':{}, 'List':{}} |
| 87 | |
| 88 | pscript.select_sidebar_menu = function(t, dt, dn) { |
| 89 | // get menu item |
| 90 | if(menu_item_map[t][dt]) { |
| 91 | // select |
| 92 | menu_item_map[t][dt].select(); |
| 93 | } else { |
| 94 | // none found :-( Unselect |
| 95 | if(cur_menu_pointer) |
| 96 | cur_menu_pointer.deselect(); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // ==================================================================== |
| 101 | // Menu pointer |
| 102 | // ==================================================================== |
| 103 | |
| 104 | var body_background = '#e2e2e2'; |
| 105 | |
| 106 | MenuPointer = function(parent, label) { |
| 107 | |
| 108 | this.wrapper = $a(parent, 'div', '', {padding:'0px', cursor:'pointer', margin:'2px 0px'}); |
| 109 | $br(this.wrapper, '3px'); |
| 110 | |
| 111 | this.tab = make_table($a(this.wrapper, 'div'), 1, 2, '100%', ['', '11px'], {height:'22px', |
| 112 | verticalAlign:'middle', padding:'0px'}, {borderCollapse:'collapse', tableLayout:'fixed'}); |
| 113 | |
| 114 | $y($td(this.tab, 0, 0), {padding:'0px 4px', color:'#444', whiteSpace:'nowrap'}); |
| 115 | |
| 116 | // triangle border (?) |
| 117 | this.tab.triangle_div = $a($td(this.tab, 0, 1), 'div','', { |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 118 | borderColor: body_background + ' ' + body_background + ' ' + body_background + ' ' + 'transparent', |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 119 | borderWidth:'11px', borderStyle:'solid', height:'0px', width:'0px', marginRight:'-11px'}); |
| 120 | |
| 121 | this.label_area = $a($td(this.tab, 0, 0), 'span', '', '', label); |
| 122 | |
| 123 | $(this.wrapper) |
| 124 | .hover( |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 125 | function() { if(!this.selected)$bg(this, '#eee'); } , |
| 126 | function() { if(!this.selected)$bg(this, body_background); } |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 127 | ) |
| 128 | |
| 129 | $y($td(this.tab, 0, 0), {borderBottom:'1px solid #ddd'}); |
| 130 | |
| 131 | } |
| 132 | |
| 133 | // ==================================================================== |
| 134 | |
| 135 | MenuPointer.prototype.select = function(grey) { |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 136 | $y($td(this.tab, 0, 0), {color:'#fff', borderBottom:'0px solid #000'}); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 137 | //$gr(this.wrapper, '#F84', '#F63'); |
| 138 | $gr(this.wrapper, '#888', '#666'); |
| 139 | this.selected = 1; |
| 140 | |
| 141 | if(cur_menu_pointer && cur_menu_pointer != this) |
| 142 | cur_menu_pointer.deselect(); |
| 143 | |
| 144 | cur_menu_pointer = this; |
| 145 | } |
| 146 | |
| 147 | // ==================================================================== |
| 148 | |
| 149 | MenuPointer.prototype.deselect = function() { |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 150 | $y($td(this.tab, 0, 0), {color:'#444', borderBottom:'1px solid #ddd'}); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 151 | $gr(this.wrapper, body_background, body_background); |
| 152 | this.selected = 0; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | // ==================================================================== |
| 157 | // Sidebar Item |
| 158 | // ==================================================================== |
| 159 | |
| 160 | var cur_sidebar_item = null; |
| 161 | |
| 162 | SidebarItem = function(det) { |
| 163 | var me = this; |
| 164 | this.det = det; |
| 165 | this.wrapper = $a(page_body.left_sidebar, 'div', '', {marginRight:'12px'}); |
| 166 | |
| 167 | this.body = $a(this.wrapper, 'div'); |
| 168 | this.tab = make_table(this.body, 1, 2, '100%', ['24px', null], {verticalAlign:'middle'}, {tableLayout:'fixed'}); |
| 169 | |
| 170 | // icon |
| 171 | var ic = $a($td(this.tab, 0, 0), 'div', 'module-icons module-icons-' + det.module_label.toLowerCase(), {marginLeft:'3px', marginBottom:'-2px'}); |
| 172 | |
| 173 | // pointer table |
| 174 | this.pointer = new MenuPointer($td(this.tab, 0, 1), det.module_label); |
| 175 | $y($td(this.pointer.tab, 0, 0), {fontWeight:'bold'}); |
| 176 | |
| 177 | // for page type |
| 178 | if(det.module_page) { |
| 179 | menu_item_map.Page[det.module_page] = this.pointer; |
| 180 | } |
| 181 | |
| 182 | // items area |
| 183 | this.items_area = $a(this.wrapper, 'div'); |
| 184 | |
| 185 | this.body.onclick = function() { me.onclick(); } |
| 186 | } |
| 187 | |
| 188 | // ==================================================================== |
| 189 | |
| 190 | SidebarItem.prototype.onclick = function() { |
| 191 | var me = this; |
| 192 | |
| 193 | if(this.det.module_page) { |
| 194 | // page type |
| 195 | this.pointer.select(); |
| 196 | |
| 197 | $item_set_working(me.pointer.label_area); |
| 198 | loadpage(this.det.module_page, function() { $item_done_working(me.pointer.label_area); }); |
| 199 | |
| 200 | } else { |
| 201 | // show sub items |
| 202 | this.toggle(); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // ==================================================================== |
| 207 | |
| 208 | SidebarItem.prototype.collapse = function() { |
| 209 | $(this.items_area).slideUp(); |
| 210 | this.is_open = 0; |
| 211 | $fg(this.pointer.label_area, '#444') |
| 212 | } |
| 213 | |
| 214 | // ==================================================================== |
| 215 | |
| 216 | SidebarItem.prototype.toggle = function() { |
| 217 | if(this.loading) return; |
| 218 | |
| 219 | if(this.is_open) { |
| 220 | this.collapse(); |
| 221 | } else { |
| 222 | if(this.loaded) $(this.items_area).slideDown(); |
| 223 | else this.show_items(); |
| 224 | this.is_open = 1; |
| 225 | $fg(this.pointer.label_area, '#000') |
| 226 | //this.pointer.select(1); |
| 227 | |
| 228 | // close existing open |
| 229 | if(cur_sidebar_item && cur_sidebar_item != this) { |
| 230 | cur_sidebar_item.collapse(); |
| 231 | } |
| 232 | cur_sidebar_item = this; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | // ==================================================================== |
| 237 | |
| 238 | SidebarItem.prototype.show_items = function() { |
| 239 | this.loading = 1; |
| 240 | var me = this; |
| 241 | |
| 242 | $item_set_working(this.pointer.label_area); |
| 243 | var callback = function(r,rt){ |
| 244 | me.loaded = 1; |
| 245 | me.loading = 0; |
| 246 | var smi = null; |
| 247 | var has_reports = 0; |
| 248 | var has_tools = 0; |
| 249 | |
| 250 | // widget code |
| 251 | $item_done_working(me.pointer.label_area); |
| 252 | |
| 253 | if(r.message.il) { |
| 254 | me.il = r.message.il; |
| 255 | |
| 256 | // forms |
| 257 | for(var i=0; i<me.il.length;i++){ |
| 258 | if(me.il[i].doc_type == 'Forms') { |
| 259 | if(in_list(profile.can_read, me.il[i].doc_name)) { |
| 260 | var smi = new SidebarModuleItem(me, me.il[i]); |
| 261 | |
| 262 | menu_item_map['Form'][me.il[i].doc_name] = smi.pointer; |
| 263 | menu_item_map['List'][me.il[i].doc_name] = smi.pointer; |
| 264 | } |
| 265 | } |
| 266 | if(me.il[i].doc_type=='Reports') has_reports = 1; |
| 267 | if(in_list(['Single DocType', 'Pages', 'Setup Forms'], me.il[i].doc_type)) has_tools = 1; |
| 268 | } |
| 269 | // reports |
| 270 | if(has_reports) { |
| 271 | var smi = new SidebarModuleItem(me, {doc_name:'Reports', doc_type:'Reports'}); |
| 272 | |
| 273 | // add to menu-item mapper |
| 274 | menu_item_map['Page'][me.det.module_label + ' Reports'] = smi.pointer; |
| 275 | } |
| 276 | |
| 277 | // tools |
| 278 | if(has_tools) { |
| 279 | var smi = new SidebarModuleItem(me, {doc_name:'Tools', doc_type:'Tools'}); |
| 280 | |
| 281 | // add to menu-item mapper |
| 282 | menu_item_map['Page'][me.det.module_label + ' Tools'] = smi.pointer; |
| 283 | } |
| 284 | |
| 285 | // custom reports |
| 286 | if(r.message.custom_reports.length) { |
| 287 | me.il = add_lists(r.message.il, r.message.custom_reports); |
| 288 | var smi = new SidebarModuleItem(me, {doc_name:'Custom Reports', doc_type:'Custom Reports'}); |
| 289 | |
| 290 | // add to menu-item mapper |
| 291 | menu_item_map['Page'][me.det.module_label + ' Custom Reports'] = smi.pointer; |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 292 | } |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 293 | } |
Rushabh Mehta | 5f66d60 | 2011-10-11 10:58:11 +0530 | [diff] [blame] | 294 | |
| 295 | if(r.login_url){ |
| 296 | login_file = 'http://' + r.login_url; |
| 297 | } |
| 298 | else if(pscript.is_erpnext_saas) { |
| 299 | login_file = 'https://www.erpnext.com'; |
| 300 | } |
| 301 | |
| 302 | |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 303 | $(me.items_area).slideDown(); |
| 304 | |
| 305 | // high light |
| 306 | var no = nav_obj.ol[nav_obj.ol.length-1]; |
| 307 | if(no && menu_item_map[decodeURIComponent(no[0])][decodeURIComponent(no[1])]) |
| 308 | pscript.select_sidebar_menu(decodeURIComponent(no[0]), decodeURIComponent(no[1])); |
| 309 | |
| 310 | } |
| 311 | |
| 312 | $c_obj('Home Control', 'get_module_details', me.det.name, callback); |
| 313 | } |
| 314 | |
| 315 | // ==================================================================== |
| 316 | // Show Reports |
| 317 | // ==================================================================== |
| 318 | |
| 319 | SidebarItem.prototype.show_section = function(sec_type) { |
| 320 | var me = this; |
| 321 | var label = this.det.module_label + ' ' + sec_type; |
| 322 | var type_map = {'Reports':'Reports', 'Custom Reports':'Custom Reports', 'Pages':'Tools', 'Single DocType':'Tools', 'Setup Forms':'Tools'} |
| 323 | |
| 324 | if(page_body.pages[label]) { |
| 325 | loadpage(label, null, 1); |
| 326 | } else { |
| 327 | // make the reports page |
| 328 | var page = page_body.add_page(label); |
| 329 | this.wrapper = $a(page,'div','layout_wrapper'); |
| 330 | |
| 331 | |
| 332 | // head |
| 333 | this.head = new PageHeader(this.wrapper, label); |
| 334 | |
| 335 | // body |
| 336 | this.body1 = $a(this.wrapper, 'div', '', {marginTop:'16px'}); |
| 337 | |
| 338 | // add a report link |
| 339 | var add_link = function(det) { |
| 340 | var div = $a(me.body1, 'div', '', {marginBottom:'6px'}); |
| 341 | var span = $a(div, 'span', 'link_type'); |
| 342 | |
| 343 | // tag the span |
| 344 | span.innerHTML = det.display_name; span.det = det; |
| 345 | if(sec_type=='Reports' || sec_type=='Custom Reports') { |
| 346 | // Reports |
| 347 | // ------- |
| 348 | span.onclick = function() { loadreport(this.det.doc_name, this.det.display_name); } |
| 349 | |
| 350 | } else { |
| 351 | // Tools |
| 352 | // ----- |
| 353 | |
| 354 | if(det.doc_type=='Pages') { |
| 355 | // Page |
| 356 | if(det.click_function) { |
| 357 | span.onclick = function() { eval(this.det.click_function) } |
| 358 | span.click_function = det.click_function; |
| 359 | } else { |
| 360 | span.onclick = function() { loadpage(this.det.doc_name); } |
| 361 | } |
| 362 | } else if(det.doc_type=='Setup Forms') { |
| 363 | // Doc Browser |
| 364 | span.onclick = function() { loaddocbrowser(this.det.doc_name); } |
| 365 | } else { |
| 366 | // Single |
| 367 | span.onclick = function() { loaddoc(this.det.doc_name, this.det.doc_name); } |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // item list |
| 373 | for(var i=0; i<me.il.length;i++){ |
| 374 | if(type_map[me.il[i].doc_type] == sec_type) { |
| 375 | add_link(me.il[i]); |
| 376 | } |
| 377 | } |
| 378 | loadpage(label, null, 1); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | |
| 383 | // ==================================================================== |
| 384 | // Sidebar module item |
| 385 | // ==================================================================== |
| 386 | |
| 387 | SidebarModuleItem = function(si, det) { |
| 388 | this.det = det; |
| 389 | var me= this; |
| 390 | |
| 391 | this.pointer = new MenuPointer(si.items_area, get_doctype_label(det.doc_name)); |
| 392 | $y(si.items_area, {marginLeft:'32px'}) |
| 393 | $y($td(this.pointer.tab, 0, 0), {fontSize:'11px'}); |
| 394 | |
| 395 | this.pointer.wrapper.onclick = function() { |
| 396 | if(me.det.doc_type=='Forms') |
| 397 | loaddocbrowser(det.doc_name); |
| 398 | else |
| 399 | si.show_section(me.det.doc_type); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | // ==================================================================== |
| 405 | // Drag & Drop order selection |
| 406 | // ==================================================================== |
| 407 | |
| 408 | pscript.startup_set_module_order = function() { |
| 409 | var update_order= function(ml) { |
| 410 | mdict = {}; |
| 411 | for(var i=0; i<ml.length; i++) { |
| 412 | mdict[ml[i][3][3]] = {'module_seq':ml[i][1], 'is_hidden':(ml[i][2] ? 'No' : 'Yes')} |
| 413 | } |
| 414 | $c_obj('Home Control', 'set_module_order', JSON.stringify(mdict), function(r,rt) { pscript.startup_make_sidebar(); } ) |
| 415 | } |
| 416 | |
| 417 | var callback = function(r, rt) { |
| 418 | var ml = []; |
| 419 | for(var i=0; i<r.message.length; i++) { |
| 420 | var det = r.message[i]; |
| 421 | ml.push([det[1], det[2], (det[3]!='No' ? 0 : 1), det[0]]); |
| 422 | } |
| 423 | new ListSelector('Set Module Sequence', 'Select items and set the order you want them to appear'+ |
| 424 | '<br><b>Note:</b> <i>These changes will apply to all users!</i>', ml, update_order, 1); |
| 425 | } |
| 426 | $c_obj('Home Control', 'get_module_order', '', callback) |
| 427 | |
| 428 | } |
| 429 | |
| 430 | // ==================================================================== |
| 431 | |
| 432 | pscript.startup_setup_toolbar = function() { |
| 433 | var menu_tab = page_body.wntoolbar.menu_table_right; |
| 434 | // Profile |
| 435 | // --------- |
| 436 | $td(menu_tab,0,0).innerHTML = '<a style="font-weight: bold; color: #FFF" href="javascript:'+"loadpage('profile-settings')"+'">'+user_fullname+'</a>'; |
| 437 | |
| 438 | if(pscript.is_erpnext_saas){ |
| 439 | // Help |
| 440 | // -------------- |
| 441 | //var help_url = login_file + '#!helpdesk' |
| 442 | $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>'; |
| 443 | |
| 444 | // Manage account |
| 445 | // -------------- |
| 446 | if(is_system_manager) { |
| 447 | $td(menu_tab,0,3).innerHTML = '<a style="font-weight: bold; color: #FFF;" href="#!billing">Billing</a>'; |
| 448 | } |
| 449 | } |
| 450 | else{ |
| 451 | $dh($td(menu_tab,0,1)); |
| 452 | $dh($td(menu_tab,0,3)); |
| 453 | } |
| 454 | |
| 455 | // Live Chat Help |
| 456 | // -------------- |
| 457 | $td(menu_tab,0,2).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">Chat</a>'; |
| 458 | |
| 459 | // help |
| 460 | // ---- |
| 461 | var cell = menu_tab.rows[0].insertCell(3); |
| 462 | cell.innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://erpnext.blogspot.com/2011/03/erpnext-help.html" target="_blank">Help</a>'; |
| 463 | $y(cell, page_body.wntoolbar.right_table_style); |
| 464 | |
| 465 | } |
| 466 | |
| 467 | // chart of accounts |
| 468 | // ==================================================================== |
| 469 | show_chart_browser = function(nm, chart_type){ |
| 470 | |
| 471 | var call_back = function(){ |
| 472 | if(nm == 'Sales Browser'){ |
| 473 | var sb_obj = new SalesBrowser(); |
| 474 | sb_obj.set_val(chart_type); |
| 475 | } |
| 476 | else if(nm == 'Accounts Browser') |
| 477 | pscript.make_chart(chart_type); |
| 478 | } |
| 479 | loadpage(nm,call_back); |
| 480 | } |
| 481 | |
| 482 | |
| 483 | // Module Page |
| 484 | // ==================================================================== |
| 485 | |
| 486 | ModulePage = function(parent, module_name, module_label, help_page, callback) { |
| 487 | this.parent = parent; |
| 488 | |
| 489 | // add to current page |
| 490 | page_body.cur_page.module_page = this; |
| 491 | |
| 492 | this.wrapper = $a(parent,'div'); |
| 493 | this.module_name = module_name; |
| 494 | this.transactions = []; |
| 495 | this.page_head = new PageHeader(this.wrapper, module_label); |
| 496 | |
| 497 | if(help_page) { |
| 498 | var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help') |
| 499 | btn.help_page = help_page; |
| 500 | } |
| 501 | |
| 502 | if(callback) this.callback = function(){ callback(); } |
| 503 | } |
| 504 | |
| 505 | |
| 506 | // get plural |
| 507 | // ==================================================================== |
| 508 | |
| 509 | get_plural = function(str){ |
| 510 | if(str.charAt(str.length-1).toLowerCase() == 'y') return str.substr(0, str.length-1) + 'ies' |
| 511 | else return str + 's'; |
| 512 | } |
| 513 | |
| 514 | // set user fullname |
| 515 | // ==================================================================== |
| 516 | pscript.set_user_fullname = function(ele,username,get_latest){ |
| 517 | |
| 518 | var set_it = function(){ |
| 519 | if(ele) |
| 520 | ele.innerHTML = user_full_nm[username]; |
| 521 | } |
| 522 | |
| 523 | if(get_latest){ |
| 524 | $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); }); |
| 525 | } |
| 526 | else{ |
| 527 | if(user_full_nm[username]){ |
| 528 | set_it(); |
| 529 | } |
| 530 | |
| 531 | else |
| 532 | $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); }); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | // ==================================================================== |
| 537 | startup_setup(); |
| 538 | |
| 539 | /* features setup "Dictionary", "Script" |
| 540 | Dictionary Format |
| 541 | 'projects': { |
| 542 | 'Sales Order': { |
| 543 | 'fields':['project_name'], |
| 544 | 'sales_order_details':['projected_qty'] |
| 545 | }, |
| 546 | 'Purchase Order': { |
| 547 | 'fields':['project_name'] |
| 548 | } |
| 549 | } |
| 550 | // ====================================================================*/ |
| 551 | pscript.feature_dict = { |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 552 | 'fs_projects': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 553 | 'Bill Of Materials': {'fields':['project_name']}, |
| 554 | 'Delivery Note': {'fields':['project_name']}, |
| 555 | 'Payable Voucher': {'fields':['project_name']}, |
| 556 | 'Production Order': {'fields':['project_name']}, |
| 557 | 'Purchase Order': {'fields':['project_name']}, |
| 558 | 'Purchase Receipt': {'fields':['project_name']}, |
| 559 | 'Receivable Voucher': {'fields':['project_name']}, |
| 560 | 'Sales Order': {'fields':['project_name']}, |
| 561 | 'Stock Entry': {'fields':['project_name']}, |
| 562 | 'Timesheet': {'timesheet_details':['project_name']} |
| 563 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 564 | 'fs_packing_details': { |
Nabin Hait | c1d4281 | 2011-10-11 12:50:55 +0530 | [diff] [blame] | 565 | '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 K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 566 | 'Sales Order': {'fields':['packing_details']} |
| 567 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 568 | 'fs_discounts': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 569 | 'Delivery Note': {'delivery_note_details':['adj_rate']}, |
| 570 | 'Quotation': {'quotation_details':['adj_rate']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 571 | 'Receivable Voucher': {'entries':['adj_rate']}, |
Brahma K | 3c9a6a1 | 2011-08-31 12:55:41 +0530 | [diff] [blame] | 572 | 'Sales Order': {'sales_order_details':['adj_rate','ref_rate']} |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 573 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 574 | 'fs_brands': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 575 | 'Delivery Note': {'delivery_note_details':['brand']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 576 | 'Indent': {'indent_details':['brand']}, |
| 577 | 'Item': {'fields':['brand']}, |
| 578 | 'Purchase Order': {'po_details':['brand']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 579 | 'Payable Voucher': {'entries':['brand']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 580 | 'Quotation': {'quotation_details':['brand']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 581 | 'Receivable Voucher': {'entries':['brand']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 582 | 'Sales BOM': {'fields':['new_item_brand']}, |
| 583 | 'Sales Order': {'sales_order_details':['brand']}, |
| 584 | 'Serial No': {'fields':['brand']} |
| 585 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 586 | 'fs_after_sales_installations': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 587 | 'Delivery Note': {'fields':['installation_status','per_installed'],'delivery_note_details':['installed_qty']} |
| 588 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 589 | 'fs_item_batch_nos': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 590 | 'Delivery Note': {'delivery_note_details':['batch_no']}, |
| 591 | 'Item': {'fields':['has_batch_no']}, |
| 592 | 'Purchase Receipt': {'purchase_receipt_details':['batch_no']}, |
| 593 | 'QA Inspection Report': {'fields':['batch_no']}, |
| 594 | 'Sales and Pruchase Return Wizard': {'return_details':['batch_no']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 595 | 'Receivable Voucher': {'entries':['batch_no']}, |
| 596 | 'Stock Entry': {'mtn_details':['batch_no']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 597 | 'Stock Ledger Entry': {'fields':['batch_no']} |
| 598 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 599 | 'fs_item_serial_nos': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 600 | 'Customer Issue': {'fields':['serial_no']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 601 | 'Delivery Note': {'delivery_note_details':['serial_no'],'packing_details':['serial_no']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 602 | 'Installation Note': {'installed_item_details':['serial_no']}, |
| 603 | 'Item': {'fields':['has_serial_no']}, |
| 604 | 'Maintenance Schedule': {'item_maintenance_details':['serial_no'],'maintenance_schedule_details':['serial_no']}, |
| 605 | 'Maintenance Visit': {'maintenance_visit_details':['serial_no']}, |
| 606 | 'Purchase Receipt': {'purchase_receipt_details':['serial_no']}, |
| 607 | 'QA Inspection Report': {'fields':['item_serial_no']}, |
| 608 | 'Sales and Pruchase Return Wizard': {'return_details':['serial_no']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 609 | 'Receivable Voucher': {'entries':['serial_no']}, |
| 610 | 'Stock Entry': {'mtn_details':['serial_no']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 611 | 'Stock Ledger Entry': {'fields':['serial_no']} |
| 612 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 613 | 'fs_item_group_in_details': { |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 614 | 'Delivery Note': {'delivery_note_details':['item_group']}, |
| 615 | 'Enquiry': {'enquiry_details':['item_group']}, |
| 616 | 'Indent': {'indent_details':['item_group']}, |
| 617 | 'Item': {'fields':['item_group']}, |
| 618 | 'Manage Account': {'fields':['default_item_group']}, |
| 619 | 'Purchase Order': {'po_details':['item_group']}, |
| 620 | 'Purchase Receipt': {'purchase_receipt_details':['item_group']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 621 | 'Purchase Voucher': {'entries':['item_group']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 622 | 'Quotation': {'quotation_details':['item_group']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 623 | 'Receivable Voucher': {'entries':['item_group']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 624 | 'Sales BOM': {'fields':['serial_no']}, |
| 625 | 'Sales Order': {'sales_order_details':['item_group']}, |
| 626 | 'Serial No': {'fields':['item_group']}, |
| 627 | 'Sales Partner': {'partner_target_details':['item_group']}, |
| 628 | 'Sales Person': {'target_details':['item_group']}, |
| 629 | 'Territory': {'target_details':['item_group']} |
| 630 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 631 | 'fs_page_break': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 632 | 'Delivery Note': {'delivery_note_details':['page_break'],'packing_details':['page_break']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 633 | 'Indent': {'indent_details':['page_break']}, |
| 634 | 'Purchase Order': {'po_details':['page_break']}, |
| 635 | 'Purchase Receipt': {'purchase_receipt_details':['page_break']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 636 | 'Purchase Voucher': {'entries':['page_break']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 637 | 'Quotation': {'quotation_details':['page_break']}, |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 638 | 'Receivable Voucher': {'entries':['page_break']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 639 | 'Sales Order': {'sales_order_details':['page_break']} |
| 640 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 641 | 'fs_exports': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 642 | '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']}, |
| 643 | 'POS Setting': {'fields':['conversion_rate','currency']}, |
| 644 | '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']}, |
| 645 | 'Receivable Voucher': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['base_ref_rate','export_amount','export_rate']}, |
| 646 | 'Item': {'ref_rate_details':['ref_currency']}, |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 647 | 'Sales BOM': {'fields':['currency']}, |
Brahma K | 8e8c482 | 2011-08-31 15:46:29 +0530 | [diff] [blame] | 648 | '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 K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 649 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 650 | 'fs_imports': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 651 | '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']}, |
| 652 | '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 K | 8e8c482 | 2011-08-31 15:46:29 +0530 | [diff] [blame] | 653 | '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']}, |
| 654 | 'Supplier Quotation': {'fields':['conversion_rate','currency']} |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 655 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 656 | 'fs_item_advanced': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 657 | 'Item': {'fields':['item_customer_details']} |
| 658 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 659 | 'fs_sales_extras': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 660 | 'Address': {'fields':['sales_partner']}, |
| 661 | 'Contact': {'fields':['sales_partner']}, |
| 662 | 'Customer': {'fields':['sales_team']}, |
| 663 | 'Delivery Note': {'fields':['sales_team','Packing List']}, |
| 664 | 'Item': {'fields':['item_customer_details']}, |
| 665 | 'Receivable Voucher': {'fields':['sales_team']}, |
| 666 | 'Sales Order': {'fields':['sales_team','Packing List']} |
| 667 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 668 | 'fs_more_info': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 669 | 'Customer': {'fields':['More Info']}, |
| 670 | 'Delivery Note': {'fields':['More Info']}, |
| 671 | 'Enquiry': {'fields':['More Info']}, |
| 672 | 'Indent': {'fields':['More Info']}, |
| 673 | 'Lead': {'fields':['More Info']}, |
| 674 | 'Payable Voucher': {'fields':['More Info']}, |
| 675 | 'Purchase Order': {'fields':['More Info']}, |
| 676 | 'Purchase Receipt': {'fields':['More Info']}, |
| 677 | 'Quotation': {'fields':['More Info']}, |
| 678 | 'Receivable Voucher': {'fields':['More Info']}, |
| 679 | 'Sales Order': {'fields':['More Info']}, |
| 680 | 'Serial No': {'fields':['More Info']}, |
| 681 | 'Supplier': {'fields':['More Info']} |
| 682 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 683 | 'fs_quality': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 684 | 'Item': {'fields':['Item Inspection Criteria','inspection_required']}, |
| 685 | 'Purchase Receipt': {'purchase_receipt_details':['qa_no']} |
| 686 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 687 | 'fs_manufacturing': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 688 | 'Item': {'fields':['Manufacturing']} |
| 689 | }, |
Nabin Hait | b30c4a6 | 2011-10-05 11:36:16 +0530 | [diff] [blame] | 690 | 'fs_pos': { |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 691 | 'Receivable Voucher': {'fields':['is_pos']} |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 692 | } |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | $(document).bind('form_refresh', function() { |
| 696 | for(sys_feat in sys_defaults) |
| 697 | { |
| 698 | if(sys_defaults[sys_feat]=='0' && (sys_feat in pscript.feature_dict)) //"Features to hide" exists |
| 699 | { |
| 700 | if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat]) |
| 701 | { |
| 702 | for(fort in pscript.feature_dict[sys_feat][cur_frm.doc.doctype]) |
| 703 | { |
| 704 | if(fort=='fields') |
| 705 | hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]); |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 706 | else if(cur_frm.fields_dict[fort]) |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 707 | { |
| 708 | for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]) |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 709 | cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 710 | } |
Brahma K | 5ecb693 | 2011-08-31 09:02:01 +0530 | [diff] [blame] | 711 | else |
| 712 | msgprint('Grid "'+fort+'" does not exists'); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 713 | } |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | }) |