{ "id": "roo-file-48", "name": "Pman.Tab.XtupleCreditMemos", "parent": "Pman.Tab.XtupleSales", "title": "Pman.Tab.XtupleCreditMemos", "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleCreditMemos.bjs", "items": [ { "listeners": { "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}" }, "background": true, "fitContainer": true, "fitToframe": true, "region": "center", "tableName": "cmhead", "title": "Credit Memos", "xtype": "GridPanel", "|xns": "Roo", "items": [ { "listeners": { "|render": "function() \n{\n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}", "|rowdblclick": "function (_self, rowIndex, e)\n{\n var s = this.dataSource.getAt(rowIndex);\n Pman.Dialog.XtupleCreditMemo.show({\n cmhead_id : s.data.cmhead_id\n },function() {\n _this.grid.footer.onClick('first');\n \n });\n/* if (!_this.dialog) return;\n _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n _this.grid.footer.onClick('first');\n }); */\n}\n" }, "*prop": "grid", "autoExpandColumn": "cmhead_cust_id_cust_name", "loadMask": true, "xtype": "Grid", "|xns": "Roo.grid", "items": [ { "listeners": { "beforeload": "function (_self, o)\n{\n if ( _this.customer && _this.customer.getValue() ) {\n o.params.cmhead_cust_id = _this.customer.getValue();\n }\n if (_this.cmnumber && _this.cmnumber.getValue() ) {\n o.params.cmhead_id = _this.cmnumber.getValue();\n }\n if (_this.status) { \n o.params['query[status]'] = _this.status.getValue();\n }\n \n o.params._with_aropen = 1;\n}" }, "*prop": "dataSource", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ field : 'cmhead_id', direction: 'DESC' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "xtype": "HttpProxy", "method": "GET", "|url": "baseURL + '/Roo/cmhead.php'", "|xns": "Roo.data" }, { "|xns": "Roo.data", "xtype": "JsonReader", "totalProperty": "total", "root": "data", "*prop": "reader", "id": "id", "|fields": "[\n {\n 'name': 'cmhead_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_number',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_posted',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_invcnumber',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_custponumber',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_cust_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_docdate',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'cmhead_shipto_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_shipto_name',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_address1',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_address2',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_address3',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_city',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_state',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_zipcode',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_salesrep_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_freight',\n 'type': 'float'\n },\n {\n 'name': 'cmhead_misc',\n 'type': 'float'\n },\n {\n 'name': 'cmhead_comments',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_printed',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_billtoname',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtoaddress1',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtoaddress2',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtoaddress3',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtocity',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtostate',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_billtozip',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_hold',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_commission',\n 'type': 'float'\n },\n {\n 'name': 'cmhead_misc_accnt_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_misc_descrip',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_rsncode_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_curr_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_freighttaxtype_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_gldistdate',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'cmhead_billtocountry',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_shipto_country',\n 'type': 'string'\n },\n {\n 'name': 'cmhead_rahead_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_taxzone_id',\n 'type': 'int'\n },\n {\n 'name': 'cmhead_prj_id',\n 'type': 'int'\n }\n]" } ] }, { "*prop": "footer", "xtype": "PagingToolbar", "pageSize": 25, "displayInfo": true, "displayMsg": "Displaying cmhead{0} - {1} of {2}", "emptyMsg": "No cmhead found", "|xns": "Roo", "items": [ { "listeners": { "click": "function (_self, e)\n{\n new Pman.Download({\n grid : _this.grid\n });\n Roo.MessageBox.alert(\"Notice\", \"Report is downloading\");\n}" }, "text": "Download", "xtype": "Button", "|xns": "Roo.Toolbar" } ] }, { "*prop": "toolbar", "xtype": "Toolbar", "|xns": "Roo", "items": [ { "listeners": { "render": "function (_self)\n{\n _this.cmnumber = _self;\n}", "select": "function (combo, record, index)\n{\n Roo.log('select');\n _this.grid.footer.onClick('first');\n}" }, "allowBlank": true, "displayField": "cmhead_number", "editable": true, "emptyText": "Order", "fieldLabel": "ordernumber", "forceSelection": true, "hiddenName": "cmhead_id", "listWidth": 400, "loadingText": "Searching...", "minChars": 2, "name": "cmhead_number", "pageSize": 20, "qtip": "Select invchead", "queryParam": "query[cmhead_number]", "selectOnFocus": true, "tpl": "
{cmhead_number}
", "triggerAction": "all", "typeAhead": false, "valueField": "cmhead_id", "width": 150, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "listeners": { "|beforeload": "function (_self, o){\n o.params = o.params || {};\n // set more here\n}\n" }, "*prop": "store", "remoteSort": true, "xtype": "Store", "|sortInfo": "{ direction : 'ASC', field: 'cmhead_number' }", "|xns": "Roo.data", "items": [ { "*prop": "proxy", "method": "GET", "xtype": "HttpProxy", "|url": "baseURL + '/Roo/cmhead.php'", "|xns": "Roo.data" }, { "*prop": "reader", "id": "cmhead_id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", "|fields": "[{\"name\":\"cmhead_id\",\"type\":\"int\"},\"cmhead_number\"]", "|xns": "Roo.data" } ] } ] }, { "listeners": { "render": "function (_self)\n{\n _this.customer = _self;\n}", "select": "function (combo, record, index)\n{\n _this.grid.footer.onClick('first');\n}" }, "allowBlank": true, "displayField": "cust_name", "editable": true, "emptyText": "Select Customer", "fieldLabel": "cust_name", "forceSelection": true, "hiddenName": "cust_id", "listWidth": 400, "loadingText": "Searching...", "minChars": 2, "name": "cust_name", "pageSize": 20, "qtip": "Select custinfo", "queryParam": "query[cust_name]", "selectOnFocus": true, "tpl": "
{cust_name}
", "triggerAction": "all", "typeAhead": false, "valueField": "cust_id", "width": 200, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "*prop": "store", "|xns": "Roo.data", "|sortInfo": "{ direction : 'ASC', field: 'cust_name' }", "xtype": "Store", "remoteSort": true, "listeners": { "|beforeload": "function (_self, o){\n o.params = o.params || {};\n // set more here\n}\n" }, "items": [ { "*prop": "proxy", "xtype": "HttpProxy", "method": "GET", "|xns": "Roo.data", "|url": "baseURL + '/Roo/custinfo.php'" }, { "*prop": "reader", "xtype": "JsonReader", "|xns": "Roo.data", "id": "cust_id", "root": "data", "totalProperty": "total", "|fields": "[{\"name\":\"cust_id\",\"type\":\"int\"},\"cust_name\"]" } ] } ] }, { "listeners": { "render": "function (_self)\n{\n _this.status = _self;\n}", "select": "function (combo, record, index)\n{\n Roo.log('select');\n _this.grid.footer.onClick('first');\n}" }, "allowBlank": false, "displayField": "fname", "editable": false, "fieldLabel": "Status", "hiddenName": "cm_status", "listWidth": 200, "mode": "local", "name": "cm_status_name", "triggerAction": "all", "value": "NOTCLOSED", "valueField": "ftype", "width": 150, "xtype": "ComboBox", "|xns": "Roo.form", "items": [ { "*prop": "store", "xtype": "SimpleStore", "|data": "[ \n [ 'NOTCLOSED', \"Not Closed\"],\n [ 'CLOSED' , \"Closed\"],\n [ 'UNPOSTED', \"Unposted only\"] ,\n [ 'UNUSED', \"Posted and not used\"] ,\n [ 'VOIDED', \"Voided\"],\n [ 'NOTVOIDED', \"Not Voided\"],\n [ 'ALL', \"Show All\"],\n]\n", "|fields": "[ 'ftype', 'fname']", "|xns": "Roo.data" } ] }, { "|xns": "Roo.Toolbar", "xtype": "Fill" }, { "cls": "x-btn-text-icon", "text": "Add", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.Toolbar", "items": [ { "|xns": "Roo.menu", "xtype": "Menu", "*prop": "menu", "items": [ { "listeners": { "click": "function (_self, e)\n{\n Pman.Dialog.XtupleCreditMemoNew.show( {} , function() {\n _this.grid.footer.onClick('first');\n }); \n\n}" }, "cls": "x-btn-text-icon", "text": "New Credit Memo", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.menu" }, { "|xns": "Roo.menu", "xtype": "Separator" }, { "listeners": { "click": "function (_self, e)\n{\n var s = _this.grid.getSelectionModel().getSelections();\n\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n } \n if(s[0].data.checkhead_total == 0){\n Roo.MessageBox.alert(\"Error\", \"you cannot create the miscellaneous check for the credit memo coz the total amount remaining is 0! \");\n return;\n }\n if(!s[0].data.cmhead_posted){\n Roo.MessageBox.alert(\"Error\", \"This credit memo has not been posted!\");\n return;\n }\n var data = {\n 'checkhead_recip_id' : s[0].data.cmhead_cust_id,\n 'checkhead_recip_type' : 'C',\n 'checkhead_checkdate' : new Date(),\n 'checkhead_amount' : s[0].data.checkhead_total,\n 'remaining_total' : s[0].data.checkhead_total,\n 'checkhead_curr_id' : s[0].data.cmhead_curr_id,\n 'checkhead_curr_id_curr_name' : s[0].data.cmhead_curr_id_curr_name,\n 'checkhead_misc' : true,\n 'aropen_id' : s[0].data.cmhead_aropen_id_aropen_id,\n \t'cmhead_number' : s[0].data.cmhead_number,\n\t'cust_name' : s[0].data.cmhead_cust_id_cust_name,\n\t'_create_and_post' : 1\n\n };\n \n \n Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {\n _this.grid.footer.onClick('first');\n }); \n\n}" }, "cls": "x-btn-text-icon", "text": "New Miscellaneous Check", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.menu" } ] } ] }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n }\n\n var postit = function()\n {\n new Pman.Request(\n {\n url : baseURL + '/Roo/Cmhead',\n mask: 'Voiding',\n method : 'POST',\n params : {\n cmhead_id : s[0].data.cmhead_id,\n _void : 1\n },\n success : function()\n {\n _this.grid.footer.onClick('refresh');\n } \n });\n \n };\n\n\n Roo.MessageBox.confirm(\n \"Confirm\",\n \"Are you sure to void this credit memo?\",\n function(r) {\n if (r != 'yes') {\n return;\n }\n postit();\n }\n );\n \n}\n" }, "cls": "x-btn-text-icon", "text": "Void Credit Memo", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n }\n if (s[0].data.cmhead_posted ) { \n Roo.MessageBox.alert(\"Error\", \n \"You can not delete posted credit memo's - you have to create an invoice to reverse them\");\n return;\n }\n \n \n\n var postit = function()\n {\n new Pman.Request(\n {\n url : baseURL + '/Roo/Cmhead',\n mask: 'Deleting',\n method : 'POST',\n params : {\n _delete : s[0].data.cmhead_id \n },\n success : function()\n {\n _this.grid.footer.onClick('refresh');\n } \n });\n \n };\n\n\n Roo.MessageBox.confirm(\n \"Confirm Deletion\",\n \"You will have to make sure this credit memo has no line items associated before deleting it. \",\n function(r) {\n if (r != 'yes') {\n return;\n }\n postit();\n }\n );\n \n}\n" }, "cls": "x-btn-text-icon", "text": "Delete Credit Memo", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "|click": "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n }\n\n var postit = function()\n {\n new Pman.Request(\n {\n url : baseURL + '/Roo/Cmhead',\n mask: 'Posting',\n method : 'POST',\n params : {\n cmhead_id : s[0].data.cmhead_id,\n _post : 1\n },\n success : function()\n {\n _this.grid.footer.onClick('refresh');\n } \n });\n \n };\n\n\n Roo.MessageBox.confirm(\n \"Confirm Posting\",\n \"Are you sure that is complete, Voiding a Credit memo invoices creating a sales order and invoice, so make sure this is correct before posting\",\n function(r) {\n if (r != 'yes') {\n return;\n }\n postit();\n }\n ); \n \n}\n" }, "cls": "x-btn-text-icon", "text": "POST", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "listeners": { "click": "function ()\n{\n var s = _this.grid.getSelectionModel().getSelected();\n if (!s || !s.data.cmhead_id) {\n Roo.MessageBox.alert(\"Error\", \"Select a credit memo\");\n return\n }\n \n var ext = baseURL.split('/').pop().replace(/\\.php/, '');\n new Pman.Download({\n url : baseURL + '/Xtuple/Print',\n params : {\n template: 'creditmemo-' + ext,\n filename : 'creditmemo-' + s.data.cmhead_id,\n 'param[0]': \"cmhead_id:string='\" + s.data.cmhead_id + \"'\"\n \n },\n method : 'GET'\n });\n Roo.MessageBox.alert(\"Notice\", \"Report will download shortly\");\n \n \n \n}" }, "cls": "x-btn-text-icon", "text": "Print", "xtype": "Button", "|icon": "rootURL + '/Pman/templates/images/pdf.gif'", "|xns": "Roo.Toolbar" }, { "|xns": "Roo.Toolbar", "xtype": "Separator" }, { "cls": "x-btn-text-icon", "text": "Tools", "xtype": "Button", "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", "|xns": "Roo.Toolbar", "items": [ { "|xns": "Roo.menu", "xtype": "Menu", "*prop": "menu", "items": [ { "|xns": "Roo.menu", "xtype": "Separator" }, { "listeners": { "click": "function (_self, e)\n{\n Roo.MessageBox.confirm(\n \"Confirm\",\n \"It is going to fill in all the blank return stock. Are you sure?\",\n function(r) {\n if (r != 'yes') {\n return;\n }\n new Pman.Request(\n {\n url : baseURL + '/Roo/Cmhead',\n mask: 'Processing',\n method : 'POST',\n params : {\n _fix_stock : 1\n },\n success : function()\n {\n Roo.MessageBox.alert('Notice','Fixed');\n _this.grid.footer.onClick('refresh');\n } \n });\n }\n ); \n}" }, "cls": "x-btn-text-icon", "text": "Fix Blank Return Stock", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.menu" } ] } ] } ] }, { "*prop": "colModel[]", "dataIndex": "cmhead_number", "header": "Ref #", "sortable": true, "width": 150, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "cmhead_docdate", "header": "Date", "sortable": true, "width": 100, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "cmhead_salesrep_id_salesrep_name", "header": "Sales Rep", "sortable": true, "width": 80, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v ); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "cust_salesrep_salesrep_name", "header": "Cust. Sales Rep", "sortable": true, "width": 80, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v ); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", ".builderCfg": "{\"table\":\"custinfo\",\"column\":\"cohead_cust_id_cust_name\",\"columnshort\":\"cust_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"Customer\"}", "dataIndex": "cmhead_cust_id_cust_name", "header": "Customer", "width": 200, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "align": "right", "dataIndex": "cmhead_curr_id_curr_symbol", "header": "Currency", "width": 70, "xtype": "ColumnModel", "|renderer": "function(v)\n{\n return String.format('{0}', v ? v : '??');\n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "align": "right", "dataIndex": "cmhead_value", "header": "Value", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v)\n{\n return Roo.util.Format.usMoney(v);\n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "align": "right", "dataIndex": "cmhead_unpaid", "header": "Open Value", "width": 100, "xtype": "ColumnModel", "|renderer": "function(v,x,r)\n{\n if (!r.data.cmhead_posted) {\n return '';\n }\n return Roo.util.Format.usMoney(v);\n}", "|xns": "Roo.grid" }, { "*prop": "colModel[]", "dataIndex": "cmhead_posted", "header": "Posted", "width": 75, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v ? 'Yes':''); }", "|xns": "Roo.grid" } ] } ] } ], "permname": "", "modOrder": "200" }