{ "name" : "Pman.Dialog.XtupleSalesOrder", "parent" : "", "title" : "", "path" : "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtupleSalesOrder.bjs", "permname" : "", "modOrder" : "001", "items" : [ { "listeners" : { "|show" : "function () {\n this.layout.getRegion('center').showPanel(0);\n}" }, "modal" : true, "collapsible" : false, "title" : "Edit / Create Sales Order", "xtype" : "LayoutDialog", "width" : 1050, "$ xns" : "Roo", "closable" : true, "resizable" : true, "height" : 620, "items" : [ { "alwaysShowTabs" : true, "xtype" : "LayoutRegion", "$ xns" : "Roo", "tabPosition" : "top", "* prop" : "center", "items" : [ { "xtype" : "Toolbar", "$ xns" : "Roo", "* prop" : "toolbar", "items" : [ { "xtype" : "Fill", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function ()\n{\n var id = 1* _this.form.findField('cohead_id').getValue();\n if (!id) {\n Roo.MessageBox.alert(\"Error\", \"Save Sales order first\");\n return;\n \n }\n // check current status of shipment..\n\n new Pman.Download({\n url : baseURL + '/Roo/cohead',\n method : 'GET',\n params : {\n cohead_id : id,\n _excel : 1\n },\n success : function() {\n\n }\n })\n \n \n \n}" }, "text" : "Download Excel", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "rootURL + '/Pman/templates/images/spreadsheet.gif'", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function ()\n{\n var id = 1* _this.form.findField('cohead_id').getValue();\n if (!id) {\n Roo.MessageBox.alert(\"Error\", \"Save Sales order first\");\n return;\n \n }\n // check current status of shipment..\n\n new Pman.Download({\n url : baseURL + '/Roo/cohead',\n method : 'GET',\n params : {\n cohead_id : id,\n _print : 1\n },\n success : function() {\n\n }\n })\n \n \n \n}" }, "text" : "Print", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "rootURL + '/Pman/templates/images/pdf.gif'", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function (_self, e)\n{\n\n _this.addShipmentBtn.fireEvent('click');\n \n}" }, "text" : "Add Shipment", "hidden" : true, "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function (_self, e)\n{\n\n Pman.Dialog.XtupleCustomer.show({\n cust_id : _this.form.findField('cohead_cust_id').getValue()\n }); \n}" }, "text" : "Edit Customer", "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "click" : "function (_self, e)\n{\n\n _this.addInvoiceBtn.fireEvent('click');\n \n}" }, "text" : "Add Invoice", "hidden" : true, "xtype" : "Button", "cls" : "x-btn-text-icon", "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "render" : "function (_self, e)\n{\n _this.voidBtn = _self;\n}", "click" : "function (_self, e)\n{\n var p = { \n cohead_id : _this.form.findField('cohead_id').getValue() \n };\n function call() {\n\n \n new Pman.Request({\n mask : 'Sending',\n url: baseURL + '/Roo/cohead',\n method : 'POST',\n params : p,\n success : function()\n {\n _this.callback();\n if ( _this.data.cohead_status == 'X') {\n _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});\n \n return;\n }\n\n \n _this.dialog.hide();\n }\n });\n }\n\n \n if (_this.data.cohead_status == 'X') {\n p._unvoid = 1;\n call();\n return;\n }\n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to void this?\", function(r) {\n \n if (r !='yes') {\n return;\n }\n p._void = 1;\n call(); \n\n \n });\n\n}" }, "text" : "Void", "xtype" : "Button", "$ xns" : "Roo.Toolbar" }, { "listeners" : { "render" : "function (_self)\n{\n _this.closeBtn = _self;\n}", "click" : "function (_self, e)\n{\n var p = { cohead_id : _this.form.findField('cohead_id').getValue() };\n \n var close = 1;\n if (_this.data.cohead_status == 'C') {\n p._reopen = 1;\n close = 0;\n } else {\n p._close = 1;\n }\n \n new Pman.Request({\n url: baseURL + '/Roo/cohead',\n method : 'POST',\n params : p,\n mask : 'Sending',\n success : function()\n {\n _this.callback();\n if (!close) {\n _this.form.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});\n \n return;\n }\n \n _this.dialog.hide();\n }\n });\n \n}" }, "text" : "Completed", "xtype" : "Button", "$ xns" : "Roo.Toolbar" } ] } ] }, { "listeners" : { "activate" : "function (_self)\n{\n // we need to reload to find out the subtotal.\n if (!_this.data || !_this.data.cohead_id) {\n return;\n }\n new Pman.Request({\n method : 'GET',\n url : baseURL + '/Roo/cohead',\n params : { \n _id : _this.data.cohead_id\n },\n success : function(res) {\n _this.form.findField('cohead_subtotal').setValue(res.data.cohead_subtotal);\n _this.form.findField('cohead_tax').setValue(res.data.cohead_tax);\n _this.form.findField('cohead_uninvoiced').setValue(res.data.cohead_uninvoiced);\n _this.form.findField('cohead_unshipped').setValue(res.data.cohead_unshipped);\n _this.form.findField('cohead_pretax_discount').setValue(res.data.cohead_pretax_discount); \n _this.form.findField('cohead_total').recalc(); \n _this.form.findField('cohead_misc').recalc(); \n }\n });\n}" }, "region" : "center", "xtype" : "ContentPanel", "title" : "Order Details", "$ xns" : "Roo", "items" : [ { "listeners" : { "actionfailed" : "function (_self, action)\n{\n if (action.failureType == 'client') {\n Roo.MessageBox.alert(\"Error\", \"Fill in all the required fields\");\n }\n if (action.failureType == 'server') { \n Roo.log(action);\n Roo.MessageBox.alert(\"Error\", action.result.errorMsg);\n }\n _this.dialog.layout.getRegion('center').showPanel(0);\n}", "|actioncomplete" : "function(_self,action)\n{\n if (action.type == 'setdata') {\n // clear the stock level cache...\n _this.stockcache = [];\n \n _this.form.findField('billto_email').setValue('');\n \n _this.reversalBtn.hide();\n \n if (_this.data.cohead_id) {\n this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});\n \n return;\n }\n _this.dialog.setTitle(\"Edit New Sales Order\");\n \n _this.closeBtn.hide();\n _this.voidBtn.hide();\n _this.saveBtn.show();\n \n if(_this.data.cohead_billto_cntct_id_cntct_id){\n _this.form.findField('billto_address').update();\n \r\n _this.form.setValues({\r\n cohead_billto_cntct_id: _this.data.cohead_billto_cntct_id_cntct_id,\r\n cohead_billto_cntct_id_cntct_name : _this.data.cohead_billto_cntct_id_cntct_name,\r\n _shipto_same : 1,\n _same_as_order : 1\n \r\n }); \r\n }\n \n return;\n }\n if (action.type == 'load') {\n \n \n _this.data = action.result.data;\n\n if (!_this.data.cohead_shipto_id && _this.data.shipto_id*1 > 0) {\n _this.form.findField('cohead_shipto_id').setValue(_this.data.shipto_id);\n _this.form.findField('cohead_shipto_id_shipto_name').setValue(_this.data.cohead_shipto_cntct_id_cntct_name);\n \n }\n \n \n _this.dataloading = true;\n if (_this.data.cohead_shipto_cntct_id == _this.data.cohead_billto_cntct_id) {\n this.findField('_shipto_same').setValue(1);\n Roo.log(\"set shipto 1\");\n } else {\n this.findField('_shipto_same').setValue(0);\n Roo.log(\"set shipto 0\");\n }\n _this.dataloading = false; \n \n \n this.findField('billto_address').update();\n this.findField('shipto_address').update(); \n _this.dialog.setTitle(\"Edit Sales Order - \" + this.findField('cohead_number').getValue());\n \n \n if (_this.data.cohead_status == 'C') {\n _this.closeBtn.show();\n _this.closeBtn.setText('Re-open');\n _this.voidBtn.hide();\n _this.saveBtn.hide();\n _this.reversalBtn.show();\n } else if (_this.data.cohead_status == 'X') {\n _this.closeBtn.hide(); \n _this.voidBtn.show(); \n _this.voidBtn.setText(\"Un-void / Re-open\"); \n _this.saveBtn.hide();\n } else {\n // it's open\n _this.closeBtn.show(); \n _this.closeBtn.setText('Complete and Close'); \n _this.voidBtn.setText(\"Void\"); \n _this.voidBtn.show(); \n _this.saveBtn.show(); \n }\n \n _this.form.findField('cohead_misc_per').update();\n \n // finally override the value for discount...\n if ((''+ _this.data.cohead_misc_descrip).length) {\n _this.form.findField('cohead_misc_descrip').setValue(_this.data.cohead_misc_descrip);\n }\n \n // update the stockcache...\n\n new Pman.Request({\n url : baseURL + '/Roo/cohead',\n method : 'GET',\n params : {\n _stockLevel : _this.data.cohead_id\n },\n success : function(res) \n {\n for (var i in res.data) {\n \n if(typeof(_this.stockcache[res.data[i].item]) == 'undefined'){\n _this.stockcache[res.data[i].item] = res.data[i];\n }\n }\n }\n });\n \n return;\n }\n if (action.type =='submit') {\n \n\n var id = _this.form.findField('cohead_id').getValue() * 1;\n if (id < 1) {\n\n _this.data.cohead_id = action.result.data.cohead_id;\n this.load({ method: 'GET', params: { '_id' : _this.data.cohead_id }});\n return;\n }\n \n _this.dialog.hide();\n \n if (_this.callback) {\n _this.callback.call(_this, _this.form.getValues());\n }\n _this.form.reset();\n return;\n }\n}\n", "|rendered" : "function (form)\n{\n _this.form= form;\n}\n" }, "$ url" : "baseURL + '/Roo/cohead.php'", "xtype" : "Form", "method" : "POST", "style" : "margin:10px;", "$ xns" : "Roo.form", "items" : [ { "xtype" : "Column", "width" : 435, "$ xns" : "Roo.form", "items" : [ { "style" : "width:420px", "legend" : "Order", "xtype" : "FieldSet", "labelWidth" : 120, "$ xns" : "Roo.form", "items" : [ { "xtype" : "Column", "labelWidth" : 100, "width" : 410, "$ xns" : "Roo.form", "items" : [ { "xtype" : "Row", "labelWidth" : 100, "width" : 400, "$ xns" : "Roo.form", "items" : [ { "fieldLabel" : "Order#", "emptyText" : "Automatic", "xtype" : "TextField", "allowBlank" : true, "readOnly" : true, "width" : 120, "$ xns" : "Roo.form", "name" : "cohead_number" }, { "style" : "float:left", "xtype" : "Row", "labelWidth" : 50, "width" : 150, "$ xns" : "Roo.form", "items" : [ { "fieldLabel" : "Cust#", "xtype" : "TextField", "allowBlank" : true, "readOnly" : true, "width" : 110, "$ xns" : "Roo.form", "name" : "cohead_cust_id_cust_number" } ] } ] }, { "listWidth" : 400, "triggerAction" : "all", "forceSelection" : true, "fieldLabel" : "Customer", "selectOnFocus" : true, "pageSize" : 20, "hiddenName" : "cohead_cust_id", "minChars" : 2, "valueField" : "cust_id", "xtype" : "TextField", "readOnly" : true, "typeAhead" : true, "editable" : false, "width" : 300, "$ xns" : "Roo.form", "name" : "cohead_cust_id_cust_name", "qtip" : "Select custinfo", "queryParam" : "query[cust_name]", "tpl" : "