/* Form page structure + this.parent (either FormContainer or Dialog) + this.wrapper + this.content + this.saved_wrapper + wn.PageLayout (this.page_layout_layout) + this.wrapper + this.wtab (table) + this.main + this.head + this.tip_wrapper + this.body + this.layout + this.footer + this.sidebar + this.print_wrapper + this.head */ // called from table edit _f.edit_record = function(dt, dn) { d = _f.frm_dialog; var show_dialog = function() { var f = frms[dt]; if(f.meta.istable) { f.parent_doctype = cur_frm.doctype; f.parent_docname = cur_frm.docname; } d.cur_frm = f; d.dn = dn; d.table_form = f.meta.istable; // show the form f.refresh(dn); } // load if(!frms[dt]) { _f.add_frm(dt, show_dialog, null); } else { show_dialog(); } } _f.Frm = function(doctype, parent) { this.docname = ''; this.doctype = doctype; this.display = 0; var me = this; this.is_editable = {}; this.opendocs = {}; this.cur_section = {}; this.sections = []; this.sections_by_label = {}; this.section_count; this.grids = []; this.cscript = {}; this.pformat = {}; this.fetch_dict = {}; this.parent = parent; this.tinymce_id_list = []; frms[doctype] = this; this.setup_meta(doctype); // notify on rename rename_observers.push(this); } // ====================================================================================== _f.Frm.prototype.setup = function() { var me = this; this.fields = []; this.fields_dict = {}; // wrapper this.wrapper = $a(this.parent.body, 'div'); // create area for print fomrat this.setup_print_layout(); // thank you goes here (in case of Guest, don't refresh, just say thank you!) this.saved_wrapper = $a(this.wrapper, 'div'); // 2 column layout this.setup_std_layout(); // client script must be called after "setup" - there are no fields_dict attached to the frm otherwise this.setup_client_script(); this.setup_done = true; } // ====================================================================================== _f.Frm.prototype.setup_print_layout = function() { this.print_wrapper = $a(this.wrapper, 'div'); this.print_head = $a(this.print_wrapper, 'div'); this.print_body = $a(this.print_wrapper,'div', 'layout_wrapper', {padding:'23px'}); var t= make_table(this.print_head, 1 ,2, '100%', [], {padding: '6px'}); this.view_btn_wrapper = $a($td(t,0,0) , 'span', 'green_buttons'); this.view_btn = $btn(this.view_btn_wrapper, 'View Details', function() { cur_frm.edit_doc() }, {marginRight:'4px'}, 'green'); this.print_btn = $btn($td(t,0,0), 'Print', function() { cur_frm.print_doc() }); $y($td(t,0,1), {textAlign: 'right'}); this.print_close_btn = $btn($td(t,0,1), 'Close', function() { nav_obj.show_last_open(); }); } _f.Frm.prototype.onhide = function() { if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect(); } // ====================================================================================== _f.Frm.prototype.setup_std_layout = function() { this.page_layout = new wn.PageLayout({ parent: this.wrapper, main_width: this.in_dialog ? '100%' : '75%', sidebar_width: this.in_dialog ? '0%' : '25%' }) this.tip_wrapper = $a(this.page_layout.toolbar_area, 'div'); // only tray this.meta.section_style='Simple'; // always simple! // layout this.layout = new Layout(this.page_layout.body, '100%'); // sidebar if(!this.in_dialog) { this.setup_sidebar(); } // footer this.setup_footer(); // header - no headers for tables and guests if(!(this.meta.istable || user=='Guest')) this.frm_head = new _f.FrmHeader(this.page_layout.head, this); // hide close btn for dialog rendering if(this.frm_head && this.meta.in_dialog) $dh(this.frm_head.page_head.close_btn); // setup tips area this.setup_tips(); // bg colour if(this.meta.colour) this.layout.wrapper.style.backgroundColor = '#'+this.meta.colour.split(':')[1]; // create fields this.setup_fields_std(); } // ====================================================================================== _f.Frm.prototype.setup_print = function() { var fl = getchildren('DocFormat', this.meta.name, 'formats', 'DocType'); var l = []; this.default_format = 'Standard'; if(fl.length) { this.default_format = fl[0].format; for(var i=0;i'; $ds(me.tip_box); if(icon) this.img.setAttribute('src','images/icons/'+icon); } this.append_tip = function(t) { me.c1.innerHTML += '
' + t + '
'; $ds(me.tip_box); } this.clear_tip = function() { me.c1.innerHTML = ''; $dh(me.tip_box); } $dh(this.tip_box); } // SETUP // ====================================================================================== _f.Frm.prototype.setup_meta = function() { this.meta = get_local('DocType',this.doctype); this.perm = get_perm(this.doctype); // for create this.setup_print(); } // -------------------------------------------------------------------------------------- _f.Frm.prototype.setup_sidebar = function() { this.sidebar = new wn.widgets.form.sidebar.Sidebar(this); } // -------------------------------------------------------------------------------------- _f.Frm.prototype.setup_footer = function() { var me = this; // footer toolbar var f = this.page_layout.footer; // save buttom f.save_area = $a(this.page_layout.footer,'div','',{display:'none'}); f.help_area = $a(this.page_layout.footer,'div'); var b = $btn(f.save_area, 'Save', function() { cur_frm.save('Save'); },{marginLeft:'0px'},'green'); // show / hide save f.show_save = function() { $ds(me.page_layout.footer.save_area); } f.hide_save = function() { $dh(me.page_layout.footer.save_area); } } // -------------------------------------------------------------------------------------- _f.Frm.prototype.setup_fields_std = function() { var fl = fields_list[this.doctype]; fl.sort(function(a,b) { return a.idx - b.idx}); if(fl[0]&&fl[0].fieldtype!="Section Break" || get_url_arg('embed')) { this.layout.addrow(); // default section break if(fl[0].fieldtype!="Column Break") {// without column too var c = this.layout.addcell(); $y(c.wrapper, {padding: '8px'}); } } var sec; for(var i=0;i