{ "id": "roo-file-37", "name": "Pman.Dialog.XtupleTransfer", "parent": "", "title": "", "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtupleTransfer.bjs", "items": [ { "listeners": { "show": "function (_self)\n{\n this.layout.getRegion('center').showPanel(0);\n}" }, "closable": false, "collapsible": false, "height": 660, "modal": true, "resizable": false, "title": "Edit / Create Inventory Transfer", "width": 800, "xtype": "LayoutDialog", "|xns": "Roo", "items": [ { "*prop": "center", "tabPosition": "top", "xtype": "LayoutRegion", "|xns": "Roo" }, { "region": "center", "title": "Inventory Transfer", "xtype": "NestedLayoutPanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "BorderLayout", "*prop": "layout", "items": [ { "*prop": "north", "height": 260, "xtype": "LayoutRegion", "|xns": "Roo" }, { "|xns": "Roo", "xtype": "LayoutRegion", "*prop": "center" }, { "region": "north", "xtype": "ContentPanel", "|xns": "Roo", "items": [ { "listeners": { "|actioncomplete": "function(_self,action)\n{\n if (action.type == 'setdata') {\n //_this.dialog.el.mask(\"Loading\");\n Roo.log('setdata');\n Roo.log(_this.data); \n // reversal...\n _this.toLocation._is_internalcompany = false;\n _this.grid.setColumns();\n _this.saveBtn.show(); \n if (_this.data.createFromRev) {\n Roo.log('recvg');\n this.load({ method: 'GET', params: { '_createFromRecv' : _this.data.createFromRev }}); \n return;\n \n }\n \n if (_this.data.invhist_transfer_id) {\n \n \n var tdb = baseURL.split('/').pop().split('.').shift();\n if (tdb != _this.data._roo_office) {\n this.el.mask('Remote Transfer - Read Only');\n _this.grid.view.headerPanel.mask(\"\");\n _this.uploadBtn.hide();\n _this.saveBtn.hide(); \n } else {\n this.el.unmask();\n _this.grid.view.headerPanel.unmask();\n _this.uploadBtn.show();\n _this.saveBtn.show(); \n }\n \n \n \n this.load({ method: 'GET', params: {\n _id : _this.data.invhist_transfer_id,\n _roo_office : _this.data._roo_office\n }});\n return;\n } \n _this.grid.ds.removeAll();\n _this.form.setValues({\n invhist_transfer_transdate : \n typeof(_this.data.invhist_transfer_transdate) == 'undefined' ? \n (new Date()).format('Y-m-d') :\n _this.data.invhist_transfer_transdate\n ,\n invhist_transfer_number : 'AUTOMATIC',\n _roo_office : _this.data._roo_office\n });\n \n if(_this.data._createReverse){\n if(_this.grid){\n new Pman.Request({\r\n url : baseURL + '/Roo/invhist_transfer_item',\r\n method : 'GET',\r\n params : {\r\n invhist_transfer_item_invhist_transfer_id : _this.data._createReverse,\r\n 'query[at_location]' : _this.data.invhist_transfer_from,\n _requestMeta : 1,\n limit : 999,\n sort : 'invhist_transfer_item_line',\n dir : 'ASC'\r\n },\r\n success : function (res) \r\n {\n Roo.log('loadData');\n Roo.log(res); \r\n _this.grid.ds.loadData(res,false);\r\n }\r\n });\n }\n }\n \n this.setValues({\n invhist_transfer_salesrep_id : Pman.Login.authUser.salesrep.salesrep_id,\n invhist_transfer_salesrep_id_salesrep_name : Pman.Login.authUser.salesrep.salesrep_name\n });\n \n \n if (typeof(_this.data._ns_autofill) != 'undefined') {\n Roo.log(\"autofill: \" + _this.data._ns_autofill);\n \n \n var locid = _this.data._ns_autofill === 1 ?_this.data.invhist_transfer_to : _this.data.invhist_transfer_from; \n // clear it so it's not done again..\n \n Roo.log(\"locid: \" + locid);\n \n var rn = 0;\n var addRow = function(r) {\n \n var nsQty = r.netsuite_qty*1;\n nsQty = nsQty < 1 ? 0 : nsQty;\n \n var ourQty = r.itemsite_qty *1;\n var addQty = 0;\n if (_this.data._ns_autofill === 1) {\n // then we are trying to transfer from somewhere to her, to increase the qty to match\n // so if ourQty < nsQty\n if (ourQty < nsQty) {\n addQty = nsQty - ourQty;\n }\n \n } else {\n // we are trying to transfer out to get rid of stock to match..\n if (nsQty < ourQty) {\n addQty = ourQty - nsQty;\n }\n }\n \n if (addQty * 1 < 1) {\n \n return;\n }\n \n var nr = _this.grid.ds.reader.newRow({\n invhist_transfer_item_line : rn + 1,\n item_id : r.itemsite_item_id, \n invhist_transfer_item_itemsite_id : r.itemsite_id, \n item_number : r.itemsite_item_id_item_number,\n item_descrip1 : r.itemsite_item_id_item_descrip1,\n invhist_transfer_item_qty : addQty,\n item_availqty : 0 \n // invhist_transfer_item_transfer_id : tid << we do not know this?!?\n });\n _this.grid.ds.insert(rn++, nr); \n \n };\n \n \n \n \n // do the request..\n new Pman.Request({\n url : baseURL + '/Roo/itemsite',\n mask: \"Fetching Stock Quantities\",\n method : 'GET',\n params : {\n limit : 99999,\n location_id : locid,\n _as_of : _this.data.invhist_transfer_transdate,\n _with_stock_and_value : 1,\n _with_ns_all_stock : 1,\n 'sort' : 'itemsite_item_id_item_number',\n 'dir' : 'ASC'\n },\n success : function(res) {\n Roo.log(res);\n Roo.each(res.data, addRow);\n _this.data._ns_autofill = undefined;\n }\n });\n }\n \n return;\n }\n if (action.type == 'load') {\n \n // fix date..\n this.findField('_roo_office').setValue( _this.data._roo_office );\n Roo.log(action);\n _this.data = action.result.data;\n \n _this.toLocation._is_internalcompany = true;\n if(!_this.data.cust_to_internalcompany || !_this.data.cust_to_internalcompany.length){\n _this.toLocation._is_internalcompany = false;\n }\n \n if(_this.data.invhist_transfer_void){\n _this.saveBtn.hide();\n }\n var dt = Date.parseDate(_this.data.invhist_transfer_transdate.split(' ')[0], \"Y-m-d\");\n _this.form.findField('invhist_transfer_transdate').setValue(dt);\n var dt = Date.parseDate(_this.data.invhist_transfer_arrivaldate.split(' ')[0],\"Y-m-d\");\n _this.form.findField('invhist_transfer_arrivaldate').setValue(dt);\n _this.grid.ds.load({});\n \n return;\n }\n if (action.type =='submit') {\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" }, "method": "POST", "style": "margin:10px;", "xtype": "Form", "|url": "baseURL + '/Xtuple/Roo/invhist_transfer.php'", "|xns": "Roo.form", "items": [ { "width": 400, "xtype": "Column", "|xns": "Roo.form", "items": [ { "legend": "Transfer Details", "style": "width: 380px;height:220px;", "xtype": "FieldSet", "|xns": "Roo.form", "items": [ { "allowBlank": false, "fieldLabel": "Date", "format": "Y-m-d", "name": "invhist_transfer_transdate", "width": 100, "xtype": "DateField", "|xns": "Roo.form" }, { "allowBlank": true, "fieldLabel": "Arrival date", "format": "Y-m-d", "name": "invhist_transfer_arrivaldate", "width": 100, "xtype": "DateField", "|xns": "Roo.form" }, { "fieldLabel": "Reference #", "name": "invhist_transfer_number", "readOnly": true, "width": 200, "xtype": "TextField", "|xns": "Roo.form" }, { "allowBlank": true, "displayField": "salesrep_name", "editable": false, "emptyText": "Select salesrep", "fieldLabel": "Sales Rep", "forceSelection": true, "hiddenName": "invhist_transfer_salesrep_id", "listWidth": 400, "loadingText": "Searching...", "minChars": 2, "name": "invhist_transfer_salesrep_id_salesrep_name", "pageSize": 20, "qtip": "Select salesrep", "queryParam": "query[salesrep_name]", "selectOnFocus": true, "tpl": "