DataObjects/Cmhead.php
[Pman.Xtuple] / Pman.Dialog.XtupleSalesOrder.bjs
1 {
2  "name" : "Pman.Dialog.XtupleSalesOrder",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtupleSalesOrder.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "58ec392a138714456f83d1288f553099" : "tracknum",
10   "42f6d99a2dddc4858882ed8e9a210b52" : "Invoice #",
11   "249ff431aa95198ad6814dd1d2799883" : "Select taxtype",
12   "fce9a6a1bd2a2050eb86d33103f46fd3" : "Invoices",
13   "a2fdeac60e3c5b6c51a92e027fb9d533" : "Target Delivery",
14   "96b0141273eabab320119c467cdcaf17" : "Total",
15   "d682c376c82f68bc65dcd05570d04dfc" : "Payments / Refunds / Credit Memos",
16   "75ba8d70e3692ba200f0e0df37b4d2ae" : "IP address",
17   "9f4f3d35db49c5c2bba70a321a42fa87" : "Find Products",
18   "9d4ba8f5211a3ba238b2032be5991c14" : "Disc%",
19   "e12167aa0a7698e6ebc92b4ce3909b53" : "To",
20   "c4a0f4ddf926328daa2a350db9f9ca00" : "Qty Changed",
21   "99575a08540e6ee585a7b389e8bde351" : "GL Tx",
22   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
23   "f84e65035f5d2d4a090b8a626c822321" : "List Price",
24   "fc44040a63559bee1157010d4c602422" : "Select location",
25   "62f0de97dd70387d493350e45bfa5583" : "Send Delivery Email",
26   "cc7819055cde3194bb3b136bad5cf58d" : " ",
27   "806dca90dbeda894ffb258939f9fef9a" : "Fill empty Ship To",
28   "fce6d3795b41b54dc0dab82df50517c1" : "Select custinfo",
29   "d323a19bad62ff427d0b75dc52674c81" : "#Ret",
30   "c5eae6ea505388a73962c635ac821fba" : "SubTotal",
31   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
32   "418c5509e2171d55b0aee5c2ea4442b5" : "action",
33   "51e07f52ae2192d23a1b43922e5beb90" : "#TX ship",
34   "607ff05a0e4c02c54b2262cd2e381aff" : "Reserve Stock / Shipments",
35   "689202409e48743b914713f96d93947c" : "Value",
36   "d9db367d7e9d6a3d3ca0346dfa1ff9d2" : "Item Description",
37   "16d2b386b2034b9488996466aaae0b57" : "History",
38   "dd7bf230fde8d4836917806aff6a6b27" : "Address",
39   "986b90fb419e5349dd59b691b0e0e9f6" : "Customer PO#",
40   "7d74f3b92b19da5e606d737d339a9679" : "Item",
41   "c5c8ac6bbc6d7f5c95d0a888527554d3" : "Order Details",
42   "fd216b286b94577ac68c112c0dcaf341" : "TX#",
43   "068f80c7519d0528fb08e82137a72131" : "Products",
44   "b166cb3a96bdb966f3288b8599594d0d" : "Sell @",
45   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
46   "151ccf95db9b81c11bb20fbc302af4b6" : "Select terms",
47   "7eb17faabef94701775df7154f30684b" : "#avail",
48   "f31bbdd1b3e85bccd652680e16935819" : "Source",
49   "086247a9b57fde6eefee2a0c4752242d" : "Automatic",
50   "0a90b1bc4078f74b6f0d117ec7df65af" : "Credit",
51   "27f2870eaa01c99fc83105240ad15f7f" : "Delete All",
52   "5f0c1431b38e3d279bf105d48824b7f3" : "Select ship to",
53   "26453198f2ddac444702879a8f6d61a5" : "Auto Reverse",
54   "780c462e85ba4399a5d42e88f69a15ca" : "Billing",
55   "81dffdb31b9576e343d3f7ffcf721d7e" : "Cost of goods",
56   "813f81532d71077e497863ec9faf16c7" : "Confirm Shipment",
57   "46fc12727bf2c5cc79988ab857ad73b4" : "Print Shipping / Commercial Invoice",
58   "8156649b9de8783c15c822b592c3bac6" : "Reverse Selected",
59   "8c6aab77edc5b8e589b36bcf989683e4" : "Print Picking Slip",
60   "69193f49683ba5a928ae8a27328105ba" : "Print Aus - GST included Invoice",
61   "13dba24862cf9128167a59100e154c8d" : "Print",
62   "4b5a5a93e13bd338d40cf4bae2ca51cb" : "Void Credit Memo",
63   "b80f4ed22929b09103f0c5666ad7a7e1" : "Run Apply Fifo on order",
64   "009534719f8c8221440a5629f497a784" : "Debit",
65   "1abe972d603f3bd61eefc9ac39fb7522" : "#TX Tot",
66   "7b09a122e58c067939744c4a96ff2d77" : "Select salesrep",
67   "56d56144d4e4a42ce450446518c4fc00" : "#Diff",
68   "03ab340b3f99e03cff9e84314ead38c0" : "Qty",
69   "f4c6f851b00d5518bf888815de279aba" : "Notes",
70   "c9cc8cce247e49bae79f15173ce97354" : "Save",
71   "386c339d37e737a436499d423a77df0c" : "Currency",
72   "f4757c5aca5e4410b63c6ec4cd0f2363" : "shiphead",
73   "f97f673be4e5f66aca62b35280d8bcde" : "Print Standard Invoice",
74   "acc95aeaee48871da70cc3bce664728c" : "Select shiptoinfo",
75   "ce26601dac0dea138b7295f02b7620a7" : "Customer",
76   "d335d558a8386d20318888b1f034103d" : "Unshipped Total",
77   "2925dda0ec274c20c0a30d8720eb830b" : "Select curr_name",
78   "72d6d7a1885885bb55a565fd1070581a" : "Import",
79   "9aa6071f39d387792476bd70fed66735" : "Void / Unconfirm",
80   "6f1bf85c9ebb3c7fa26251e1e335e032" : "Terms",
81   "53896265ad28c11cb4997b3c3e3e122d" : "#Ship",
82   "5da618e8e4b89c66fe86e32cdafde142" : "From",
83   "158e64bcd08067d26e9c27679eeced88" : "No Items",
84   "d179a904ac10a39ab574fe803cc29fa3" : "Run Void flagger",
85   "f3d90c6982143029487fb00d4ef19526" : "#invoiced",
86   "80092f7900d59aab765d0ddd35dc7231" : "Add Shipment",
87   "a240fa27925a635b08dc28c9e4f9216d" : "Order",
88   "01d35df7886d24900b1ecb65da6bf21d" : "Receive Payment",
89   "f817f797c422f7ac3404b6223db1a1ee" : "invdetail",
90   "50104a28589c5b6099d3580861c2551a" : "Shipments / Invoices",
91   "e23841a1d7427d8a9297142145dff049" : "Select shipto",
92   "9f1a342d0197aac60ed73e921dc4c1f5" : "Price Details",
93   "2142511303396bd51e0cc25ea8ffe47f" : "Void Payment",
94   "88408722ed9d719c44087292bf8a06cf" : "Prices with GST",
95   "236119342501b1e596bc82013c9cfc42" : "SubTotal w/GST",
96   "4b78ac8eb158840e9638a3aeb26c4a9d" : "Tax",
97   "cb02c723b8a159fea3cd7913d3df7fbc" : "Doc#",
98   "6a813cbab5d0c9d33b1a471839935d88" : "Cust#",
99   "b8feb9ee933bc5cc05615860322e9e7a" : "Post Invoice",
100   "70c6ddcd97af88d0aaac48268c459727" : "Download (as xls)",
101   "66b2bba3de9b8c5d6fb94e9458f1b7f5" : "Show Inventory History",
102   "57cdc7bcd2ca327f3267e2f5ecfa8c6d" : "Edit / Create Sales Order",
103   "48e91c2f1cb7b90612ccae2502c7327f" : "Shipment Comments",
104   "47cb03899dc494703b52c37240fa4c17" : "Stock Tx",
105   "72bb7a9ea8714c52b0c0b8369d6a8dc3" : "Issue Date",
106   "e5d63551ca2d2842661e49a25fd12a67" : "Edit Customer",
107   "7608203603437f0513ba8203a2d39a4f" : "Item Code",
108   "08bd40c7543007ad06e4fce31618f6ec" : "Account",
109   "e963218370d6410e1ee0f8e6128c12d4" : "shipdate",
110   "0ee182201463a0ea31cb073b227fbbbe" : "Print Chinese Invoice With GST in line item",
111   "089ba2b5edc96565fc22c584ecfbb1a6" : "Displaying events{0} - {1} of {2}",
112   "0bcef9c45bd8a48eda1b26eb0c61c869" : "%",
113   "81ceb48a978444906d80119200aa358d" : "Void",
114   "a763436d2b30d54e4aff264b1636827a" : "Discount (Pretax)",
115   "4721299f56b6b7d43591156d1d3f3e82" : "List Price w/GST",
116   "f4ac45b9eb622dcb26c0d4fc1c93b27c" : "Order Comments",
117   "7a113dee68a51f4c5f71264fd0ce3781" : "Item#",
118   "a860ed9926b241b7d4dca2d00610ab2c" : "Outstanding",
119   "290612199861c31d1036b185b4e69b75" : "Summary",
120   "786410e93beb0193d89f8608c54feb4b" : "Select item",
121   "b1bc248a7ff2b2e95569f56de68615df" : "number",
122   "07ca5050e697392c9ed47e6453f1453f" : "Completed",
123   "6b15347cbd1bf352b547741a7525c1b4" : "#shipped",
124   "b3c65c9f85b429821cf931b38386a64d" : "Select Tax Type",
125   "5e33fc1550a56738da96fbaaf57e72f0" : "#TX ret",
126   "16cd452dda9d4398bf6240603eee40a9" : "Posted",
127   "b2f40690858b404ed10e62bdf422c704" : "Amount",
128   "e87de1a5d238411ab34a292be599e9f4" : "Apply To All",
129   "40e6e8652d174c7ceef48df46f9cf25a" : "From Location",
130   "9122d60c0550be8ab070b96d8bbc6358" : "Sell @w/GST",
131   "78ca8a8170f2065057507ddcde63d9ca" : "Tax Zone",
132   "757989a16207ab23076685118640adf3" : "Item Cost",
133   "160ab8f9d6c5d2819fff11dea08d4ef8" : "Download Excel",
134   "0ee72ad23c24d7cfc5c13311abdc3f72" : "Staff I.C.",
135   "511b6a78f5503881ba10ff93b7205ade" : "Create CM reversal",
136   "74002cb040b036511b8d031da591364a" : "Ship to",
137   "c6b4fd215b0cdcb7426519edc0ece828" : "Print Bambini Pro Forma Invoice",
138   "b98c34417c412e0c87faa828f26b9123" : "Uninvoiced Total",
139   "a0d036a1d6a00180df168fa86143e5f8" : "No invdetail found",
140   "de3d17fb46f44fdf066581fbb5fe6113" : "Select Staff",
141   "fbb9d6ec5325d0fe63c19431856a0802" : "Select cntct",
142   "c3ce05eb16c5e0075b4a247b2c4b7bba" : "Bill To (select)",
143   "ec53a8c4f07baed5d8825072c89799be" : "Status",
144   "25d81668fca34c83d0720cc6365d62d6" : "Pre Tax discount",
145   "b25f6c965342495f74899e183efe20a4" : "Void / Unpost",
146   "58733ee735e3160c5c9fa5739fb4d056" : "Unposted",
147   "3ec365dd533ddb7ef3d1c111186ce872" : "Details",
148   "c04b33241cc5478500daf178e3720b63" : "No coitem found",
149   "ea9cf7e47ff33b2be14e6dd07cbcefc6" : "Shipping",
150   "871080cb9d00a8bda1b9f1db3c164341" : "Unit Cost",
151   "820dbd2b8f606aff866c0bbfb6b737c1" : "Changed",
152   "7ce96513eec175e6123b56573750b0dd" : "#reserved",
153   "a0ec87054b5e5b7847d0d8780a01a3d5" : "Sum",
154   "26e09a1ee1517389c7b07f42df65561a" : "Ordered",
155   "bdd31bfe5374e3cdc19a10020eae4b49" : "Add Invoice",
156   "801ab24683a4a8c433c6eb40c48bcd9d" : "Download",
157   "44749712dbec183e983dcd78a7736c41" : "Date",
158   "37656f0f6cf5e5befb1ec7abd3db5804" : "shipvia",
159   "4a2a14210d78f0d82db75d0264030169" : "Supply From",
160   "052fbb9431206b4755090dc53fcef300" : "Void Refund",
161   "c4b515058fab313f403ae427ce7e32b3" : "Update Location to match S/O",
162   "87813307f6e7498b30c5b3d9b2f65f56" : "Displaying invdetail{0} - {1} of {2}",
163   "3a6a3353e3b44ad5359c8e3178b66a54" : "invcdate",
164   "4b84bd35233c0d3d3c36b9a6ce6e0745" : "Order Items",
165   "13abfee28b4564e3fb059420fbedbec5" : "Taxed",
166   "94f475efc6722fd13ab78411c1ef7bd7" : "Sales Rep",
167   "bb4af85913879b95661b81570a2c2e83" : "Discount (Posttax)",
168   "526db6366257755024ed2556000871bc" : "Issue Refund",
169   "594f5bdc5e1519ce9934d276e5bf081f" : "No events found",
170   "d0cc96be641673ad48fc74374fda8137" : "Displaying coitem{0} - {1} of {2}",
171   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
172   "b6dad11e8e2203819164d64fc82b40f1" : "Discount after Tax  Description",
173   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
174   "1b7132f58f9ee9de75e5778ff04f7303" : "Print Delivery Note",
175   "4ee972120bcda675f75222c87cb9d356" : "Who",
176   "a0947dda65e4112f49260243804b6528" : "Xfer all stock to HK",
177   "1d144309cbdf2536723621bf0eac9f33" : "or enter Address",
178   "3d96cc39e5517a284e203ffc8cafcf51" : "Print Bambini Pronto Invoice",
179   "9c9745a343efeacc9efe9b7222b27afb" : "Ref#",
180   "c43b0fbe81e21c0a874a155ce528eebf" : "Apply % Discount of : ",
181   "e8586011952b0d098b0e568f20ca2b1f" : "Select Currency",
182   "fa1cfdb383ea976facbdb20d40d2f811" : "Duplicate Selected",
183   "6ac26fe4e9a39ac45fffe6d6920dac3a" : "Print Chinese Invoice",
184   "182875b6c36a761f1e459624c1d93638" : "Profit",
185   "3ffaf70863d6f46e2719050a37d9ef86" : "Order#",
186   "8fb8fbc1c0bc53b2d01121344410e444" : "Split sales",
187   "09466661df2abefeecf849e52fce8fb4" : "Total "
188  },
189  "items" : [
190   {
191    "listeners" : {
192     "|show" : "function () {\n       this.layout.getRegion('center').showPanel(0);\n}"
193    },
194    "modal" : true,
195    "collapsible" : false,
196    "title" : "Edit / Create Sales Order",
197    "xtype" : "LayoutDialog",
198    "width" : 1050,
199    "$ xns" : "Roo",
200    "closable" : true,
201    "resizable" : true,
202    "height" : 620,
203    "items" : [
204     {
205      "alwaysShowTabs" : true,
206      "xtype" : "LayoutRegion",
207      "$ xns" : "Roo",
208      "tabPosition" : "top",
209      "* prop" : "center",
210      "items" : [
211       {
212        "xtype" : "Toolbar",
213        "$ xns" : "Roo",
214        "* prop" : "toolbar",
215        "items" : [
216         {
217          "xtype" : "Fill",
218          "$ xns" : "Roo.Toolbar"
219         },
220         {
221          "listeners" : {
222           "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}"
223          },
224          "text" : "Download Excel",
225          "xtype" : "Button",
226          "cls" : "x-btn-text-icon",
227          "$ icon" : "rootURL + '/Pman/templates/images/spreadsheet.gif'",
228          "$ xns" : "Roo.Toolbar"
229         },
230         {
231          "listeners" : {
232           "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}"
233          },
234          "text" : "Print",
235          "xtype" : "Button",
236          "cls" : "x-btn-text-icon",
237          "$ icon" : "rootURL + '/Pman/templates/images/pdf.gif'",
238          "$ xns" : "Roo.Toolbar"
239         },
240         {
241          "listeners" : {
242           "click" : "function (_self, e)\n{\n\n    _this.addShipmentBtn.fireEvent('click');\n   \n}"
243          },
244          "text" : "Add Shipment",
245          "hidden" : true,
246          "xtype" : "Button",
247          "cls" : "x-btn-text-icon",
248          "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
249          "$ xns" : "Roo.Toolbar"
250         },
251         {
252          "listeners" : {
253           "click" : "function (_self, e)\n{\n\n   Pman.Dialog.XtupleCustomer.show({\n         cust_id : _this.form.findField('cohead_cust_id').getValue()\n  }); \n}"
254          },
255          "text" : "Edit Customer",
256          "xtype" : "Button",
257          "cls" : "x-btn-text-icon",
258          "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
259          "$ xns" : "Roo.Toolbar"
260         },
261         {
262          "listeners" : {
263           "click" : "function (_self, e)\n{\n\n        _this.addInvoiceBtn.fireEvent('click');\n   \n}"
264          },
265          "text" : "Add Invoice",
266          "hidden" : true,
267          "xtype" : "Button",
268          "cls" : "x-btn-text-icon",
269          "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
270          "$ xns" : "Roo.Toolbar"
271         },
272         {
273          "listeners" : {
274           "render" : "function (_self, e)\n{\n    _this.voidBtn = _self;\n}",
275           "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}"
276          },
277          "text" : "Void",
278          "xtype" : "Button",
279          "$ xns" : "Roo.Toolbar"
280         },
281         {
282          "listeners" : {
283           "render" : "function (_self)\n{\n   _this.closeBtn = _self;\n}",
284           "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}"
285          },
286          "text" : "Completed",
287          "xtype" : "Button",
288          "$ xns" : "Roo.Toolbar"
289         }
290        ]
291       }
292      ]
293     },
294     {
295      "listeners" : {
296       "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}"
297      },
298      "region" : "center",
299      "xtype" : "ContentPanel",
300      "title" : "Order Details",
301      "$ xns" : "Roo",
302      "items" : [
303       {
304        "listeners" : {
305         "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}",
306         "|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",
307         "|rendered" : "function (form)\n{\n    _this.form= form;\n}\n"
308        },
309        "$ url" : "baseURL + '/Roo/cohead.php'",
310        "xtype" : "Form",
311        "method" : "POST",
312        "style" : "margin:10px;",
313        "$ xns" : "Roo.form",
314        "items" : [
315         {
316          "xtype" : "Column",
317          "width" : 435,
318          "$ xns" : "Roo.form",
319          "items" : [
320           {
321            "legend" : "Order",
322            "xtype" : "FieldSet",
323            "style" : "width:420px",
324            "labelWidth" : 120,
325            "$ xns" : "Roo.form",
326            "items" : [
327             {
328              "xtype" : "Column",
329              "labelWidth" : 100,
330              "width" : 410,
331              "$ xns" : "Roo.form",
332              "items" : [
333               {
334                "xtype" : "Row",
335                "labelWidth" : 100,
336                "width" : 400,
337                "$ xns" : "Roo.form",
338                "items" : [
339                 {
340                  "fieldLabel" : "Order#",
341                  "emptyText" : "Automatic",
342                  "xtype" : "TextField",
343                  "allowBlank" : true,
344                  "readOnly" : true,
345                  "width" : 120,
346                  "$ xns" : "Roo.form",
347                  "name" : "cohead_number"
348                 },
349                 {
350                  "style" : "float:left",
351                  "xtype" : "Row",
352                  "labelWidth" : 50,
353                  "width" : 150,
354                  "$ xns" : "Roo.form",
355                  "items" : [
356                   {
357                    "fieldLabel" : "Cust#",
358                    "xtype" : "TextField",
359                    "allowBlank" : true,
360                    "readOnly" : true,
361                    "width" : 110,
362                    "$ xns" : "Roo.form",
363                    "name" : "cohead_cust_id_cust_number"
364                   }
365                  ]
366                 }
367                ]
368               },
369               {
370                "listWidth" : 400,
371                "triggerAction" : "all",
372                "forceSelection" : true,
373                "fieldLabel" : "Customer",
374                "selectOnFocus" : true,
375                "pageSize" : 20,
376                "hiddenName" : "cohead_cust_id",
377                "minChars" : 2,
378                "valueField" : "cust_id",
379                "xtype" : "TextField",
380                "readOnly" : true,
381                "typeAhead" : true,
382                "editable" : false,
383                "width" : 300,
384                "$ xns" : "Roo.form",
385                "name" : "cohead_cust_id_cust_name",
386                "qtip" : "Select custinfo",
387                "queryParam" : "query[cust_name]",
388                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b> </div>",
389                "loadingText" : "Searching..."
390               },
391               {
392                "fieldLabel" : "Customer PO#",
393                "xtype" : "TextField",
394                "$ xns" : "Roo.form",
395                "width" : 150,
396                "name" : "cohead_custponumber"
397               },
398               {
399                "format" : "Y-m-d",
400                "fieldLabel" : "Ordered",
401                "xtype" : "DateField",
402                "allowBlank" : false,
403                "width" : 100,
404                "$ xns" : "Roo.form",
405                "name" : "cohead_orderdate"
406               },
407               {
408                "xtype" : "Row",
409                "labelWidth" : 100,
410                "width" : 500,
411                "$ xns" : "Roo.form",
412                "items" : [
413                 {
414                  "format" : "Y-m-d",
415                  "fieldLabel" : "Target Delivery",
416                  "xtype" : "DateField",
417                  "allowBlank" : false,
418                  "width" : 100,
419                  "$ xns" : "Roo.form",
420                  "name" : "cohead_targetdate"
421                 },
422                 {
423                  "hideLabels" : true,
424                  "xtype" : "Row",
425                  "$ xns" : "Roo.form",
426                  "items" : [
427                   {
428                    "listeners" : {
429                     "check" : "function (_self, checked)\n{\n    if(checked){\n        _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());\n    }\n}"
430                    },
431                    "inputValue" : 1,
432                    "xtype" : "Checkbox",
433                    "boxLabel" : "same as order",
434                    "$ xns" : "Roo.form",
435                    "name" : "_same_as_order"
436                   }
437                  ]
438                 }
439                ]
440               },
441               {
442                "listWidth" : 400,
443                "triggerAction" : "all",
444                "fieldLabel" : "Supply From",
445                "forceSelection" : true,
446                "selectOnFocus" : true,
447                "pageSize" : 200,
448                "displayField" : "location_name",
449                "emptyText" : "Supply From",
450                "hiddenName" : "cohead_location_src",
451                "minChars" : 2,
452                "valueField" : "location_id",
453                "xtype" : "ComboBox",
454                "allowBlank" : false,
455                "typeAhead" : false,
456                "editable" : true,
457                "width" : 300,
458                "$ xns" : "Roo.form",
459                "name" : "cohead_location_src_location_name",
460                "qtip" : "Select terms",
461                "queryParam" : "query[location_name]",
462                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{location_name}</b> {location_descrip} </div>",
463                "loadingText" : "Searching...",
464                "items" : [
465                 {
466                  "listeners" : {
467                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n     o.params.location_netable = 1;\n      o.params.location_restrict = 0;\n      o.params._notinternalcompany = 1;\n}\n"
468                  },
469                  "xtype" : "Store",
470                  "remoteSort" : true,
471                  "$ sortInfo" : "{ direction : 'ASC', field: 'location_name' }",
472                  "$ xns" : "Roo.data",
473                  "* prop" : "store",
474                  "items" : [
475                   {
476                    "$ url" : "baseURL + '/Roo/location.php'",
477                    "xtype" : "HttpProxy",
478                    "method" : "GET",
479                    "$ xns" : "Roo.data",
480                    "* prop" : "proxy"
481                   },
482                   {
483                    "id" : "location_id",
484                    "root" : "data",
485                    "xtype" : "JsonReader",
486                    "$ fields" : "[{\"name\":\"location_id\",\"type\":\"int\"},\"location_name\"]",
487                    "$ xns" : "Roo.data",
488                    "* prop" : "reader",
489                    "totalProperty" : "total"
490                   }
491                  ]
492                 }
493                ]
494               }
495              ]
496             }
497            ]
498           },
499           {
500            "legend" : "Details",
501            "xtype" : "FieldSet",
502            "style" : "width:420px",
503            "labelWidth" : 100,
504            "$ xns" : "Roo.form",
505            "items" : [
506             {
507              "xtype" : "Column",
508              "labelWidth" : 100,
509              "width" : 420,
510              "$ xns" : "Roo.form",
511              "items" : [
512               {
513                "listWidth" : 400,
514                "triggerAction" : "all",
515                "forceSelection" : true,
516                "selectOnFocus" : true,
517                "fieldLabel" : "Terms",
518                "pageSize" : 20,
519                "xtype" : "ComboBox",
520                "emptyText" : "Select terms",
521                "minChars" : 2,
522                "valueField" : "terms_id",
523                "displayField" : "terms_descrip",
524                "hiddenName" : "cohead_terms_id",
525                "allowBlank" : false,
526                "typeAhead" : true,
527                "editable" : false,
528                "$ xns" : "Roo.form",
529                "width" : 300,
530                "qtip" : "Select terms",
531                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{terms_descrip}</b> </div>",
532                "queryParam" : "query[terms_descrip]",
533                "name" : "cohead_terms_id_terms_descrip",
534                "loadingText" : "Searching...",
535                "items" : [
536                 {
537                  "listeners" : {
538                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
539                  },
540                  "xtype" : "Store",
541                  "remoteSort" : true,
542                  "$ sortInfo" : "{ direction : 'ASC', field: 'terms_descrip' }",
543                  "$ xns" : "Roo.data",
544                  "* prop" : "store",
545                  "items" : [
546                   {
547                    "$ url" : "baseURL + '/Roo/terms.php'",
548                    "method" : "GET",
549                    "xtype" : "HttpProxy",
550                    "$ xns" : "Roo.data",
551                    "* prop" : "proxy"
552                   },
553                   {
554                    "id" : "terms_id",
555                    "root" : "data",
556                    "xtype" : "JsonReader",
557                    "$ xns" : "Roo.data",
558                    "$ fields" : "[{\"name\":\"terms_id\",\"type\":\"int\"},\"terms_descrip\"]",
559                    "* prop" : "reader",
560                    "totalProperty" : "total"
561                   }
562                  ]
563                 }
564                ]
565               },
566               {
567                "alwaysQuery" : true,
568                "listWidth" : 400,
569                "triggerAction" : "all",
570                "fieldLabel" : "Sales Rep",
571                "forceSelection" : true,
572                "selectOnFocus" : true,
573                "pageSize" : 80,
574                "displayField" : "salesrep_name",
575                "emptyText" : "Select salesrep",
576                "hiddenName" : "cohead_display_salesrep_id",
577                "minChars" : 2,
578                "valueField" : "salesrep_id",
579                "xtype" : "ComboBox",
580                "allowBlank" : true,
581                "typeAhead" : true,
582                "editable" : false,
583                "width" : 300,
584                "$ xns" : "Roo.form",
585                "name" : "cohead_display_salesrep_id_salesrep_name",
586                "qtip" : "Select salesrep",
587                "queryParam" : "query[salesrep_name]",
588                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>",
589                "loadingText" : "Searching...",
590                "items" : [
591                 {
592                  "listeners" : {
593                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
594                  },
595                  "xtype" : "Store",
596                  "remoteSort" : true,
597                  "$ sortInfo" : "{ direction : 'ASC', field: 'salesrep_name' }",
598                  "$ xns" : "Roo.data",
599                  "* prop" : "store",
600                  "items" : [
601                   {
602                    "$ url" : "baseURL + '/Roo/salesrep.php'",
603                    "method" : "GET",
604                    "xtype" : "HttpProxy",
605                    "$ xns" : "Roo.data",
606                    "* prop" : "proxy"
607                   },
608                   {
609                    "id" : "salesrep_id",
610                    "root" : "data",
611                    "xtype" : "JsonReader",
612                    "$ xns" : "Roo.data",
613                    "$ fields" : "[{\"name\":\"salesrep_id\",\"type\":\"int\"},\"salesrep_name\"]",
614                    "* prop" : "reader",
615                    "totalProperty" : "total"
616                   }
617                  ]
618                 }
619                ]
620               },
621               {
622                "alwaysQuery" : true,
623                "listWidth" : 400,
624                "triggerAction" : "all",
625                "fieldLabel" : "Staff I.C.",
626                "forceSelection" : true,
627                "selectOnFocus" : true,
628                "pageSize" : 80,
629                "displayField" : "salesrep_name",
630                "emptyText" : "Select Staff",
631                "hiddenName" : "cohead_salesrep_id",
632                "minChars" : 2,
633                "valueField" : "salesrep_id",
634                "xtype" : "ComboBox",
635                "allowBlank" : false,
636                "typeAhead" : true,
637                "editable" : false,
638                "width" : 300,
639                "$ xns" : "Roo.form",
640                "name" : "cohead_salesrep_id_salesrep_name",
641                "qtip" : "Select salesrep",
642                "queryParam" : "query[salesrep_name]",
643                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>",
644                "loadingText" : "Searching...",
645                "items" : [
646                 {
647                  "listeners" : {
648                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
649                  },
650                  "xtype" : "Store",
651                  "remoteSort" : true,
652                  "$ sortInfo" : "{ direction : 'ASC', field: 'salesrep_name' }",
653                  "$ xns" : "Roo.data",
654                  "* prop" : "store",
655                  "items" : [
656                   {
657                    "$ url" : "baseURL + '/Roo/salesrep.php'",
658                    "method" : "GET",
659                    "xtype" : "HttpProxy",
660                    "$ xns" : "Roo.data",
661                    "* prop" : "proxy"
662                   },
663                   {
664                    "id" : "salesrep_id",
665                    "root" : "data",
666                    "xtype" : "JsonReader",
667                    "$ xns" : "Roo.data",
668                    "$ fields" : "[{\"name\":\"salesrep_id\",\"type\":\"int\"},\"salesrep_name\"]",
669                    "* prop" : "reader",
670                    "totalProperty" : "total"
671                   }
672                  ]
673                 }
674                ]
675               },
676               {
677                "fieldLabel" : "Order Comments",
678                "xtype" : "TextArea",
679                "width" : 300,
680                "$ xns" : "Roo.form",
681                "name" : "cohead_ordercomments",
682                "height" : 80
683               }
684              ]
685             }
686            ]
687           },
688           {
689            "xtype" : "FieldSet",
690            "legend" : "Billing",
691            "style" : "width:420px",
692            "$ xns" : "Roo.form",
693            "items" : [
694             {
695              "xtype" : "Column",
696              "labelWidth" : 50,
697              "width" : 420,
698              "$ xns" : "Roo.form",
699              "items" : [
700               {
701                "listeners" : {
702                 "add" : "function (combo)\n{\n  \n  Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n               \n                for(var i in  data) {\n                    \n                    _this.data['cohead_billto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('billto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_billto_cntct_id : data.cntct_id,\n                    cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n            }\n        );\n        //  Pman.Dialog.XtupleCustomer.show(\n            //{ cust_id : _this.form.findField('cohead_cust_id').getValue() }, \n            //function(data) {\n        // refresh the data in the pulldown..\n    //    }); \n\n}",
703                 "beforeselect" : "function (combo, record, index)\n{\n    // set _this.data values ..\n\n    // just add everything...\n    for(var i in record.data) {\n        _this.data['cohead_billto_cntct_id_' + i] = record.data[i];\n    }\n    \n    _this.form.findField('billto_address').update();\n    \n    \n \n}"
704                },
705                "alwaysQuery" : true,
706                "listWidth" : 400,
707                "triggerAction" : "all",
708                "fieldLabel" : "Bill To (select)",
709                "forceSelection" : true,
710                "selectOnFocus" : true,
711                "pageSize" : 20,
712                "displayField" : "cntct_name",
713                "emptyText" : "Select cntct",
714                "hiddenName" : "cohead_billto_cntct_id",
715                "minChars" : 2,
716                "valueField" : "cntct_id",
717                "xtype" : "ComboBox",
718                "allowBlank" : false,
719                "typeAhead" : true,
720                "editable" : true,
721                "width" : 300,
722                "$ xns" : "Roo.form",
723                "name" : "cohead_billto_cntct_id_cntct_name",
724                "qtip" : "Select cntct",
725                "queryParam" : "query[cntct_name]",
726                "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>",
727                "loadingText" : "Searching...",
728                "items" : [
729                 {
730                  "listeners" : {
731                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params._customer_id = _this.data.cohead_cust_id;\n}\n"
732                  },
733                  "xtype" : "Store",
734                  "remoteSort" : true,
735                  "$ sortInfo" : "{ direction : 'ASC', field: 'cntct_name' }",
736                  "$ xns" : "Roo.data",
737                  "* prop" : "store",
738                  "items" : [
739                   {
740                    "$ url" : "baseURL + '/Roo/cntct.php'",
741                    "method" : "GET",
742                    "xtype" : "HttpProxy",
743                    "$ xns" : "Roo.data",
744                    "* prop" : "proxy"
745                   },
746                   {
747                    "id" : "cntct_id",
748                    "root" : "data",
749                    "xtype" : "JsonReader",
750                    "$ xns" : "Roo.data",
751                    "$ fields" : "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]",
752                    "* prop" : "reader",
753                    "totalProperty" : "total"
754                   }
755                  ]
756                 }
757                ]
758               },
759               {
760                "listeners" : {
761                 "render" : "function (_self)\n{\n   Roo.log(this.el)\n   \n   \n   \n   this.el.on('click', function() { \n       var id = _this.form.findField('cohead_billto_cntct_id').getValue();\n        Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n            \n                for(var i in  data) {\n                    \n                    _this.data['cohead_billto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('billto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_billto_cntct_id : data.cntct_id,\n                    cohead_billto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n                \n                        \n                Roo.log(data);\n            }\n        );\n   \n        Roo.log(\"Click text\");\n        \n        \n     });\n}"
762                },
763                "fieldLabel" : "or enter Address",
764                "xtype" : "TextArea",
765                "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_' +e].length) { \n            v.push(_this.data['cohead_billto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e].length) {\n            v.push(_this.data['cohead_billto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n    \n    if(_this.data.cohead_billto_cntct_id_cntct_email.length){\n        _this.form.findField('billto_email').setValue(_this.data.cohead_billto_cntct_id_cntct_email);\n    }\n}\n",
766                "readOnly" : true,
767                "$ xns" : "Roo.form",
768                "name" : "billto_address"
769               },
770               {
771                "fieldLabel" : "Email",
772                "xtype" : "DisplayField",
773                "$ valueRenderer" : "function(v)\n{\n \n    return v ? String.format('<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>',v) : '';\n}",
774                "$ xns" : "Roo.form",
775                "name" : "billto_email"
776               }
777              ]
778             }
779            ]
780           }
781          ]
782         },
783         {
784          "xtype" : "Column",
785          "style" : "margin-left:10px",
786          "width" : 435,
787          "$ xns" : "Roo.form",
788          "items" : [
789           {
790            "xtype" : "FieldSet",
791            "style" : "width:420px",
792            "legend" : "Price Details",
793            "labelWidth" : 50,
794            "$ xns" : "Roo.form",
795            "items" : [
796             {
797              "labelAlign" : "right",
798              "xtype" : "Column",
799              "labelWidth" : 300,
800              "width" : 420,
801              "$ xns" : "Roo.form",
802              "items" : [
803               {
804                "labelAlign" : "top",
805                "xtype" : "Row",
806                "labelSeparator" : "&nbsp;",
807                "width" : 500,
808                "$ xns" : "Roo.form",
809                "items" : [
810                 {
811                  "listeners" : {
812                   "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n    Roo.log('beforequery');\n   \n    if (_this.form.findField('cohead_number').getValue().length) {\n        Roo.MessageBox.alert(\"Error\", \"You can not change the currency of this order\");\n        if (query) {\n            query.cancel = true;\n        }\n        return false;\n    }\n}"
813                  },
814                  "listWidth" : 400,
815                  "triggerAction" : "all",
816                  "fieldLabel" : "Currency",
817                  "forceSelection" : true,
818                  "selectOnFocus" : true,
819                  "pageSize" : 20,
820                  "displayField" : "curr_name",
821                  "emptyText" : "Select curr_name",
822                  "hiddenName" : "cohead_curr_id",
823                  "minChars" : 2,
824                  "valueField" : "curr_id",
825                  "xtype" : "ComboBox",
826                  "allowBlank" : false,
827                  "typeAhead" : true,
828                  "editable" : false,
829                  "width" : 285,
830                  "$ xns" : "Roo.form",
831                  "name" : "cohead_curr_id_curr_name",
832                  "qtip" : "Select Currency",
833                  "queryParam" : "query[curr_name]",
834                  "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{curr_name}</b> </div>",
835                  "loadingText" : "Searching...",
836                  "items" : [
837                   {
838                    "listeners" : {
839                     "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n   \n}\n"
840                    },
841                    "xtype" : "Store",
842                    "remoteSort" : true,
843                    "$ sortInfo" : "{ direction : 'ASC', field: 'curr_symbol' }",
844                    "$ xns" : "Roo.data",
845                    "* prop" : "store",
846                    "items" : [
847                     {
848                      "$ url" : "baseURL + '/Roo/curr_symbol.php'",
849                      "method" : "GET",
850                      "xtype" : "HttpProxy",
851                      "$ xns" : "Roo.data",
852                      "* prop" : "proxy"
853                     },
854                     {
855                      "id" : "curr_id",
856                      "root" : "data",
857                      "xtype" : "JsonReader",
858                      "$ xns" : "Roo.data",
859                      "$ fields" : "[{\"name\":\"curr_id\",\"type\":\"int\"},\"curr_symbol\"]",
860                      "* prop" : "reader",
861                      "totalProperty" : "total"
862                     }
863                    ]
864                   }
865                  ]
866                 },
867                 {
868                  "fieldLabel" : "Products",
869                  "xtype" : "NumberField",
870                  "cls" : "roo-align-right",
871                  "readOnly" : true,
872                  "allowDecimals" : true,
873                  "decimalPrecision" : 3,
874                  "width" : 100,
875                  "$ xns" : "Roo.form",
876                  "name" : "cohead_subtotal"
877                 }
878                ]
879               },
880               {
881                "labelAlign" : "top",
882                "xtype" : "Row",
883                "labelSeparator" : "&nbsp;",
884                "width" : 500,
885                "$ xns" : "Roo.form",
886                "items" : [
887                 {
888                  "listeners" : {
889                   "select" : "function (combo, record, index)\n{\n     _this.form.findField('cohead_tax').setValue(\n             parseFloat(record.data.taxzone_rate) * \n             parseFloat(_this.form.findField('cohead_subtotal').getValue())\n     );\n      _this.form.findField('cohead_total').recalc();\n}"
890                  },
891                  "listWidth" : 400,
892                  "triggerAction" : "all",
893                  "fieldLabel" : "Tax Zone",
894                  "forceSelection" : true,
895                  "selectOnFocus" : true,
896                  "pageSize" : 20,
897                  "displayField" : "taxzone_descrip",
898                  "emptyText" : "Select taxtype",
899                  "hiddenName" : "cohead_taxzone_id",
900                  "minChars" : 2,
901                  "valueField" : "taxzone_id",
902                  "xtype" : "ComboBox",
903                  "allowBlank" : false,
904                  "typeAhead" : true,
905                  "editable" : false,
906                  "width" : 285,
907                  "$ xns" : "Roo.form",
908                  "name" : "cohead_taxzone_id_taxzone_descrip",
909                  "qtip" : "Select taxtype",
910                  "queryParam" : "query[taxzone_descrip]",
911                  "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{taxzone_descrip}</b> </div>",
912                  "loadingText" : "Searching...",
913                  "items" : [
914                   {
915                    "listeners" : {
916                     "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    \n    o.params.with_date = _this.form.findField('cohead_orderdate').getValue().format('Y-m-d'); \n    Roo.log(\"with date?\" + o.params.with_date);\n    \n    \n}\n"
917                    },
918                    "xtype" : "Store",
919                    "remoteSort" : true,
920                    "$ sortInfo" : "{ direction : 'ASC', field: 'taxzone_descrip' }",
921                    "$ xns" : "Roo.data",
922                    "* prop" : "store",
923                    "items" : [
924                     {
925                      "$ url" : "baseURL + '/Roo/taxzone.php'",
926                      "xtype" : "HttpProxy",
927                      "method" : "GET",
928                      "$ xns" : "Roo.data",
929                      "* prop" : "proxy"
930                     },
931                     {
932                      "id" : "taxzone_id",
933                      "root" : "data",
934                      "xtype" : "JsonReader",
935                      "$ fields" : "[{\"name\":\"taxzone_id\",\"type\":\"int\"},\"taxzone_descrip\"]",
936                      "$ xns" : "Roo.data",
937                      "* prop" : "reader",
938                      "totalProperty" : "total"
939                     }
940                    ]
941                   }
942                  ]
943                 },
944                 {
945                  "fieldLabel" : "Tax",
946                  "xtype" : "NumberField",
947                  "cls" : "roo-align-right",
948                  "readOnly" : true,
949                  "allowDecimals" : true,
950                  "decimalPrecision" : 3,
951                  "width" : 100,
952                  "$ xns" : "Roo.form",
953                  "name" : "cohead_tax"
954                 }
955                ]
956               },
957               {
958                "fieldLabel" : "Pre Tax discount",
959                "xtype" : "NumberField",
960                "cls" : "roo-align-right",
961                "readOnly" : true,
962                "allowDecimals" : true,
963                "decimalPrecision" : 3,
964                "width" : 100,
965                "$ xns" : "Roo.form",
966                "name" : "cohead_pretax_discount"
967               },
968               {
969                "labelAlign" : "top",
970                "xtype" : "Row",
971                "labelSeparator" : "&nbsp;",
972                "width" : 500,
973                "$ xns" : "Roo.form",
974                "items" : [
975                 {
976                  "fieldLabel" : "Discount after Tax  Description",
977                  "xtype" : "TextField",
978                  "width" : 230,
979                  "$ xns" : "Roo.form",
980                  "name" : "cohead_misc_descrip"
981                 },
982                 {
983                  "listeners" : {
984                   "keyup" : "function (_self, e)\n{\n    var pv =  parseFloat(_this.form.findField('cohead_subtotal').getValue());\n    var tax = parseFloat(_this.form.findField('cohead_tax').getValue());\n    var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());\n    \n    var n = this.getValue();\n    var discount = parseFloat(n * (pv + tax + pd) * 0.01);\n    \n    _this.form.findField('cohead_posttax_discount').setValue(discount);\n\n    _this.form.findField('cohead_total').recalc();\n    _this.form.findField('cohead_misc').recalc();\n    var val = discount * -1.0;\n     if (val > 0) {\n        _this.form.findField('cohead_misc_descrip').setValue(\"Discount of \" + val.toFixed(1)+'%');\n    }\n   \n    \n}"
985                  },
986                  "fieldLabel" : "%",
987                  "xtype" : "NumberField",
988                  "$ update" : "function() {\n    var m = _this.form.findField('cohead_misc_per');\n    var pv =  parseFloat(_this.form.findField('cohead_subtotal').getValue());\n    var tax = parseFloat(_this.form.findField('cohead_tax').getValue());\n    var pd = parseFloat(_this.form.findField('cohead_pretax_discount').getValue());\n    \n    var discount = parseFloat(_this.form.findField('cohead_posttax_discount').getValue());\n    \n    if (discount > 0.0) {\n        this.setValue(0);        \n        return;\n    }\n    if (pv < 0) {\n        this.setValue(0);        \n        return;\n    }\n    var val = ((discount) / (pv + tax + pd)) * -100;\n    \n    //Roo.log(\"update discount?\" + val);\n    this.setValue(val.toFixed(1));\n    \n     if (val > 0.0) {\n        _this.form.findField('cohead_misc_descrip').setValue(\"Discount of \" + val.toFixed(1)+'%');\n    \n    }\n    \n   \n}\n",
989                  "cls" : "roo-align-right",
990                  "allowDecimals" : true,
991                  "decimalPrecision" : 1,
992                  "width" : 35,
993                  "$ xns" : "Roo.form",
994                  "name" : "cohead_misc_per"
995                 },
996                 {
997                  "listeners" : {
998                   "keyup" : "function (_self, e)\n{\n   _this.form.findField('cohead_misc_per').update();\n    _this.form.findField('cohead_total').recalc();\n    _this.form.findField('cohead_misc').recalc();\n}"
999                  },
1000                  "fieldLabel" : "&nbsp;",
1001                  "xtype" : "NumberField",
1002                  "cls" : "roo-align-right",
1003                  "allowDecimals" : true,
1004                  "decimalPrecision" : 3,
1005                  "width" : 100,
1006                  "$ xns" : "Roo.form",
1007                  "name" : "cohead_posttax_discount"
1008                 }
1009                ]
1010               },
1011               {
1012                "fieldLabel" : "Total",
1013                "$ recalc" : "function() {\n    var d = _this.form.getValues();\n    this.setValue( \n                parseFloat(d.cohead_subtotal) + \n                parseFloat(d.cohead_pretax_discount) + \n                parseFloat(d.cohead_posttax_discount) + \n                parseFloat(d.cohead_tax) + \n                parseFloat(d.cohead_freight));\n}\n",
1014                "xtype" : "NumberField",
1015                "cls" : "roo-align-right",
1016                "readOnly" : true,
1017                "allowDecimals" : true,
1018                "decimalPrecision" : 3,
1019                "width" : 100,
1020                "$ xns" : "Roo.form",
1021                "name" : "cohead_total"
1022               },
1023               {
1024                "listeners" : {
1025                 "keyup" : "function (_self, e)\n{\n    _this.form.findField('cohead_total').recalc();\n}"
1026                },
1027                "fieldLabel" : "Shipping",
1028                "xtype" : "NumberField",
1029                "cls" : "roo-align-right",
1030                "allowDecimals" : true,
1031                "decimalPrecision" : 3,
1032                "width" : 100,
1033                "$ xns" : "Roo.form",
1034                "name" : "cohead_freight"
1035               },
1036               {
1037                "fieldLabel" : "Unshipped Total",
1038                "xtype" : "NumberField",
1039                "cls" : "roo-align-right",
1040                "readOnly" : true,
1041                "allowDecimals" : true,
1042                "decimalPrecision" : 3,
1043                "width" : 100,
1044                "$ xns" : "Roo.form",
1045                "name" : "cohead_unshipped"
1046               },
1047               {
1048                "fieldLabel" : "Uninvoiced Total",
1049                "xtype" : "NumberField",
1050                "cls" : "roo-align-right",
1051                "readOnly" : true,
1052                "allowDecimals" : true,
1053                "decimalPrecision" : 3,
1054                "width" : 100,
1055                "$ xns" : "Roo.form",
1056                "name" : "cohead_uninvoiced"
1057               }
1058              ]
1059             }
1060            ]
1061           },
1062           {
1063            "xtype" : "FieldSet",
1064            "legend" : "Shipping",
1065            "style" : "width:420px",
1066            "$ xns" : "Roo.form",
1067            "items" : [
1068             {
1069              "xtype" : "Column",
1070              "labelWidth" : 50,
1071              "width" : 420,
1072              "$ xns" : "Roo.form",
1073              "items" : [
1074               {
1075                "xtype" : "Row",
1076                "labelSeparator" : "&nbsp;",
1077                "$ xns" : "Roo.form",
1078                "items" : [
1079                 {
1080                  "listeners" : {
1081                   "check" : "function (_self, checked)\n{\n   if (!_this.form) {\n       return;\n   }\n   \n   if (_this.dataloading) {\n   \n       return;\n   }\n   \n   \n   if (checked) {\n   \n        // copy the cohead_billto_cntct_id\n        for (var i in _this.data) {\n            if (!i.match(/^cohead_billto_cntct_id/)) {\n                continue;\n            }\n            var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');\n            _this.data[ni] = _this.data[i];\n        }\n         _this.form.findField('shipto_address').update();\n         _this.form.setValues( {\n                cohead_shipto_cntct_id : _this.data.cohead_shipto_cntct_id,\n                cohead_shipto_cntct_id_cntct_name : _this.data.cohead_shipto_cntct_id_cntct_first_name + ' ' + \n                        _this.data.cohead_shipto_cntct_id_cntct_last_name \n                        \n                \n            });\n\n   \n    } else {\n         for (var i in _this.data) {\n            if (!i.match(/^cohead_billto_cntct_id/)) {\n                continue;\n            }\n            var ni = i.replace(/^cohead_billto_cntct_id/, 'cohead_shipto_cntct_id');\n            \n            _this.data[ni] = '';\n        }\n         _this.form.findField('shipto_address').update();\n         \n        _this.form.setValues( {\n                cohead_shipto_cntct_id : '',\n                cohead_shipto_cntct_id_cntct_name : '' \n                \n                \n            });\n    }\n    \n}"
1082                  },
1083                  "xtype" : "Checkbox",
1084                  "boxLabel" : "Same as Billing",
1085                  "$ xns" : "Roo.form",
1086                  "name" : "_shipto_same"
1087                 }
1088                ]
1089               },
1090               {
1091                "listeners" : {
1092                 "add" : "function (combo)\n{\n Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n               \n                for(var i in  data) {\n                    \n                    _this.data['cohead_shipto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('shipto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_shipto_cntct_id : data.cntct_id,\n                    cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n            }\n        ); \n}",
1093                 "beforeselect" : "function (combo, record, index)\n{\n   \n    // just add everything...\n    for(var i in record.data) {\n        //Roo.log('cohead_shipto_cntct_id_' + i +' ='  + record.data[i]);\n        _this.data['cohead_shipto_cntct_id_' + i] = record.data[i];\n    }\n\n    _this.form.findField('shipto_address').update();\n    \n \n}"
1094                },
1095                "alwaysQuery" : true,
1096                "listWidth" : 400,
1097                "triggerAction" : "all",
1098                "fieldLabel" : "Ship to",
1099                "forceSelection" : true,
1100                "selectOnFocus" : true,
1101                "pageSize" : 20,
1102                "displayField" : "cntct_name",
1103                "emptyText" : "Select ship to",
1104                "hiddenName" : "cohead_shipto_cntct_id",
1105                "minChars" : 2,
1106                "valueField" : "cntct_id",
1107                "xtype" : "ComboBox",
1108                "allowBlank" : false,
1109                "typeAhead" : true,
1110                "editable" : true,
1111                "width" : 300,
1112                "$ xns" : "Roo.form",
1113                "name" : "cohead_shipto_cntct_id_cntct_name",
1114                "qtip" : "Select shiptoinfo",
1115                "queryParam" : "query[cntct_name]",
1116                "tpl" : "<div class=\"x-grid-cell-text x-btn button\">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>",
1117                "loadingText" : "Searching...",
1118                "items" : [
1119                 {
1120                  "listeners" : {
1121                   "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params._customer_id = _this.data.cohead_cust_id;\n}\n"
1122                  },
1123                  "xtype" : "Store",
1124                  "remoteSort" : true,
1125                  "$ sortInfo" : "{ direction : 'ASC', field: 'cntct_name' }",
1126                  "$ xns" : "Roo.data",
1127                  "* prop" : "store",
1128                  "items" : [
1129                   {
1130                    "$ url" : "baseURL + '/Roo/cntct.php'",
1131                    "method" : "GET",
1132                    "xtype" : "HttpProxy",
1133                    "$ xns" : "Roo.data",
1134                    "* prop" : "proxy"
1135                   },
1136                   {
1137                    "id" : "cntct_id",
1138                    "root" : "data",
1139                    "xtype" : "JsonReader",
1140                    "$ xns" : "Roo.data",
1141                    "$ fields" : "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]",
1142                    "* prop" : "reader",
1143                    "totalProperty" : "total"
1144                   }
1145                  ]
1146                 }
1147                ]
1148               },
1149               {
1150                "listeners" : {
1151                 "render" : "function (_self)\n{\n   Roo.log(this.el)\n   \n   \n   \n   this.el.on('click', function() { \n       var id = _this.form.findField('cohead_shipto_cntct_id').getValue();\n        Pman.Dialog.XtupleQuickContact.show( \n            {\n              _id : id,\n              customer_id : _this.form.findField('cohead_cust_id').getValue()\n            },\n            \n            function (data) {\n            \n                for(var i in  data) {\n                    \n                    _this.data['cohead_shipto_cntct_id_' + i] =  data[i];\n                }\n                \n                _this.form.findField('shipto_address').update();\n                // fill in the select box..\n                _this.form.setValues( {\n                    cohead_shipto_cntct_id : data.cntct_id,\n                    cohead_shipto_cntct_id_cntct_name : data.cntct_first_name + ' '+ \n                            data.cntct_last_name\n                    \n                });\n                \n                        \n                //Roo.log(data);\n            }\n        );\n   \n      //  Roo.log(\"Click text\");\n        \n        \n     });\n}"
1152                },
1153                "fieldLabel" : "Address",
1154                "xtype" : "TextArea",
1155                "$ update" : "function() {\n\n    var c = ['first_name', 'last_name' ] ;\n    var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];\n    var v = [];\n    \n    if (_this.data['cohead_shipto_vend_name'] && _this.data['cohead_shipto_vend_name'].length) {\n         v.push(_this.data['cohead_shipto_vend_name']);\n    }\n        if (_this.data['cohead_shipto_vendaddr_code'] && _this.data['cohead_shipto_vendaddr_code'].length) {\n         v.push(_this.data['cohead_shipto_vendaddr_code']);\n    }\n    Roo.each(c, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_' +e].length) {\n            v.push(_this.data['cohead_shipto_cntct_id_cntct_' +e]);\n        }\n    });\n    Roo.each(a, function(e) {\n        if (_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e] && \n            _this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e].length) { \n            v.push(_this.data['cohead_shipto_cntct_id_cntct_addr_id_addr_' +e]);\n        }\n    });\n\n    this.setValue(v.join(\"\\n\"));\n}\n",
1156                "readOnly" : true,
1157                "width" : 300,
1158                "$ xns" : "Roo.form",
1159                "name" : "shipto_address"
1160               },
1161               {
1162                "fieldLabel" : "Shipment Comments",
1163                "xtype" : "TextArea",
1164                "$ xns" : "Roo.form",
1165                "width" : 300,
1166                "name" : "cohead_shipcomments"
1167               }
1168              ]
1169             }
1170            ]
1171           }
1172          ]
1173         },
1174         {
1175          "xtype" : "Hidden",
1176          "$ xns" : "Roo.form",
1177          "name" : "cohead_id"
1178         },
1179         {
1180          "xtype" : "Hidden",
1181          "$ xns" : "Roo.form",
1182          "name" : "cohead_shipto_id"
1183         },
1184         {
1185          "xtype" : "Hidden",
1186          "$ xns" : "Roo.form",
1187          "name" : "cohead_shipto_id_shipto_name"
1188         },
1189         {
1190          "xtype" : "Hidden",
1191          "$ xns" : "Roo.form",
1192          "name" : "cohead_max_linenumber"
1193         },
1194         {
1195          "xtype" : "Hidden",
1196          "$ xns" : "Roo.form",
1197          "name" : "cohead_cust_id"
1198         },
1199         {
1200          "$ recalc" : "function() {\n    var d = _this.form.getValues();\n    this.setValue( \n        parseFloat(d.cohead_pretax_discount) + \n        parseFloat(d.cohead_posttax_discount) );\n}\n",
1201          "xtype" : "Hidden",
1202          "$ xns" : "Roo.form",
1203          "name" : "cohead_misc"
1204         },
1205         {
1206          "xtype" : "Hidden",
1207          "$ xns" : "Roo.form",
1208          "name" : "taxzone_rate"
1209         }
1210        ]
1211       }
1212      ]
1213     },
1214     {
1215      "listeners" : {
1216       "deactivate" : "function (_self)\n{\n    if(_this.grid){\n        _this.grid.stopEditing();\n    }\n}",
1217       "|activate" : "function() {\n    _this.panel = this;\n    \n    try { if (MODULE.isBuilder) {\n        return;\n    } } catch(e) { }\n    \n    var id = _this.form.findField('cohead_id').getValue() * 1;\n    if (id < 1) {\n        Roo.MessageBox.alert(\"Save First\", \"Save the order first, before adding items\");\n        _this.dialog.layout.getRegion('center').showPanel(0);\n        return;\n    }\n    \n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    \n         //if (_this.form.findField('cohead_cust_id_cust_name').getValue() == 'Bloom and Grow HK') {\n         //   _this.xferAll.show();\n        // \n        // } else {\n        //     _this.xferAll.hide();\n        // }\n     }\n    \n}"
1218      },
1219      "background" : true,
1220      "region" : "center",
1221      "fitToframe" : true,
1222      "title" : "Order Items",
1223      "xtype" : "GridPanel",
1224      "fitContainer" : true,
1225      "$ xns" : "Roo",
1226      "tableName" : "coitem",
1227      "items" : [
1228       {
1229        "listeners" : {
1230         "beforeedit" : "function (e)\n{\n    // we can only edit if nothing is assigned to shipping or invoices..\n    \n    var rec = e.record\n\n    if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0 || (rec.data.shipitem_shipped - rec.data.coitem_qtyshipped) > 0 ) {\n        Roo.MessageBox.alert(\"Error\", \"That item has been shipped, has a draft shipment  or invoices - void the shipments/invoices first\");\n        e.cancel = true;\n        return;\n    }\n    \n    if (rec.data.coitem_subnumber * 1 > 0) {\n        Roo.log(\"Edit container event\");\n        Roo.log(e); // if it's a tab.. \n\n        \n        switch(e.field) {\n            // allow editing of source / destination..\n            case 'coitem_shipto_id':\n            case 'coitem_location_src':            \n                return;\n            default : \n                break;\n        }\n        Roo.MessageBox.alert(\"Error\", \"That is a kit item, edit the container.\");\n        e.cancel = true;\n        return;\n    }\n    // zero off values..\n    //if (e.field == 'coitem_qtyord' && rec.data.coitem_qtyord == 0) {\n    //        e.value ='';\n    //    }\n    //    if (e.field == 'coitem_custprice' && rec.data.coitem_qtyord == 0.0) {\n    //        e.value ='';\n    //    }\n    \n    if (rec.data.item_type == 'K' && e.field == 'item_number') {\n        // you can not change the product type on kits' as it messing things up..\n        Roo.MessageBox.alert(\"Error\", \"That is a kit item,if you need to change it, delete it first.\");\n        e.cancel = true;\n        return;\n    }\n    \n}",
1231         "|render" : "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    \n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
1232         "celldblclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    var di = this.cm.getDataIndex(columnIndex);\n    if (di != 'avail_qty') {\n        return;\n    }\n    \n    Pman.Dialog.XtupleInvHistory.show({\n        itemsite_item_id_item_number   : rec.data.item_number,\n       // itemsite_item_id_item_descript1 : rec.data.item_descrip1,\n        location_name : rec.data.coitem_location_src_location_name,\n        location_descrip : rec.data.coitem_location_src_location_descrip,\n        \n        invhist_transdate : _this.form.findField('cohead_targetdate').getValue() \n    }); \n    \n}",
1233         "afteredit" : "function (e)\n{\n    Roo.log('afteredit:' + e.record.data.coitem_linenumber);\n\n    \n   // if ( e.record && e.record.data.coitem_id) {\n        // as we disable update to the display on the ajax callback to \n        // allow editing flow to continue, and not refresh - we can only update\n        // these values after something has actually been edited.\n        // e.record.set('coitem_id', e.record.data.coitem_id);\n        // e.record.set('coitem_status', e.record.data.coitem_status);\n   // }\n    \n    if (e.field == 'item_number' || e.originalValue == e.value) {\n        // afterselect handles this...\n        return;\n    }\n    if (e.field == 'item_descrip1') {\n        e.record.set('coitem_memo', e.value);\n    }\n    var rate = _this.form.findField('taxzone_rate').getValue();\n    switch(e.field) {\n        case 'coitem_linedisc':\n           \n            var cp = parseFloat(e.record.data.coitem_custprice);\n           \n            if (isNaN(cp) || cp == 0.0) {\n                break;\n            }\n            \n            var dis = parseFloat(e.value);\n           \n            if (isNaN(dis)) {\n                break;\n            }\n            \n            e.record.set(\n                'coitem_price',\n                Math.max(0,cp * ((100.0 -  parseInt(e.value))/ 100.0) )  \n            );\n            \n           // donot need to set the subtotal here, coz we will render it automatically\n           // e.record.set(\n           //     'coitem_subtotal',\n           //      e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord\n           // );\n            break;\n        \n        case  'coitem_price': // SELL@ price\n\n             var cp = parseFloat(e.record.data.coitem_custprice);\n             // list price is < price -- update it..\n             if (isNaN(cp) || cp == 0.0 || cp < e.value) {\n                e.record.set('coitem_custprice', e.value);\n                cp = e.value;\n             }\n             // update the discount calc.\n             \n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( e.value / cp) * 100.0)));  \n             \n             // donot need to set the subtotal here, coz we will render it automatically\n             //e.record.set(\n             //   'coitem_subtotal',\n              //   e.record.data.coitem_price * 1.0 * e.record.data.coitem_qtyord\n             //);\n             break;\n        \n        case 'coitem_custprice':\n            // modified customer price...\n            // just modify the discount.. -- leave the entered price the same..\n              var sp =  parseFloat(e.record.data.coitem_price);\n              var cp = parseFloat(e.value);\n              if (isNaN(cp) || cp == 0.0 || cp < e.value) {\n                    break;\n              }\n              \n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break;\n             \n        case 'coitem_custprice_tax':\n              var cp = parseFloat(e.value / ( 1 + rate * 1 ));\n              var sp =  parseFloat(e.record.data.coitem_price);\n              \n              if (isNaN(cp) || cp == 0.0) {\n                    break;\n              }\n              e.record.set('coitem_custprice', cp);\n              e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break; \n             \n         case  'coitem_price_tax':\n\n             var cp = parseFloat(e.record.data.coitem_custprice);\n             var sp = parseFloat(e.value / ( 1 + rate * 1 ));\n             if (isNaN(cp) || cp == 0.0 || cp < sp) {\n                e.record.set('coitem_custprice', sp);\n                cp = sp;\n             }\n             e.record.set('coitem_price', sp);\n             e.record.set('coitem_linedisc', Math.max(0, 100.0 -  (( sp / cp) * 100.0)));  \n             \n             break;\n      \n    }\n    \n     \n    \n    \n    var doupdate = function() { \n       if (!e.record.updatePending) {\n            Roo.log('doupdate...'  + e.record.data.coitem_linenumber);\n            Roo.log(e.record);\n            e.record.commit();\n            return;\n        }\n       Roo.log('doupdate pending...'   + e.record.data.coitem_linenumber);\n        // wait until it's not peding an update..\n        doupdate.defer(500);\n    }\n\n    if(e.record.data.coitem_id * 1 < 1 && !e.record.isInserting){ // insert\n        e.record.isInserting = 1;\n        e.record.isUpdating = 0;\n        doupdate();\n        return;\n    }\n    \n    // update\n    if(!e.record.isInserting && !e.record.isUpdating){\n        e.record.isUpdating = 1;\n        doupdate();\n        return;\n    }\n    \n    if(!e.record.updatePending){\n        e.record.updatePending = 1;\n        doupdate();\n        return;\n    }\n    Roo.log(\"got to end without doing an update?\"  + e.record.data.coitem_linenumber);\n    \n}\n",
1234         "rowclass" : "function (gridview, rowcfg)\n{\n    if (rowcfg.record.data.coitem_status == 'C' &&\n        rowcfg.record.data.shipitem_shipped * 1 < 1) {\n        \n        rowcfg.rowClass = 'strikethrough';\n    }\n     if (rowcfg.record.data.coitem_status == 'X'  ) {\n        \n        rowcfg.rowClass = 'strikethrough';\n    }\n    \n    if (!rowcfg.record.data.coitem_id) { \n            rowcfg.rowClass = 'dragon-not-saved';\n    }\n    \n    \n   // Roo.log(rowcfg);\n//    shipitem_shipped\n}"
1235        },
1236        "autoExpandColumn" : "item_descrip1",
1237        "xtype" : "EditorGrid",
1238        "loadMask" : true,
1239        "$ loadAvail" : "function() {\n    \n    \n    this.ds.each(function(r) {\n        \n        if(!r.data.item_number.length){\n            return;\n        }\n        \n        if(typeof(_this.stockcache[r.data.item_number]) != 'undefined'){\n        \n            r.set('avail_qty', _this.stockcache[r.data.item_number].qty);\n            if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {\n                r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);\n            }\n            return;\n        }\n        \n        var q = [];\n        \n        q.push( { \n            item : r.data.item_number, \n            loc: r.data.coitem_location_src_location_name,\n            id: r.data.coitem_linenumber + (r.data.coitem_subnumber ? ('.' + r.data.coitem_subnumber) : '')\n         } );\n         \n         new Pman.Request({\n            url : baseURL + '/Roo/itemloc',\n            method : 'POST',\n            params : {\n                _availqty : Roo.encode(q),\n                curr_name : _this.form.findField('cohead_curr_id').el.dom.value\n            },\n            success : function(res) \n            {\n                for (var i in res.data) {\n                   _this.stockcache[res.data[i].item] = res.data[i];\n                }\n                r.set('avail_qty', _this.stockcache[r.data.item_number].qty);\n                if (r.data.coitem_unitcost_in_order_cur * 1.0 < 0.1) {\n                    r.set('coitem_unitcost_in_order_cur', _this.stockcache[r.data.item_number].unitcost);\n                }\n                //_this.grid.ds.fireEvent(\"update\", _this.grid.ds, r, Roo.data.Record.EDIT);\n                return\n            }\n        });\n    });\n        \n                \n}\n",
1240        "clicksToEdit" : 1,
1241        "$ xns" : "Roo.grid",
1242        "* prop" : "grid",
1243        "items" : [
1244         {
1245          "listeners" : {
1246           "tabend" : "function (_self)\n{\n    _this.addItemBtn.fireEvent('click', _this.addItemBtn);\n}",
1247           "beforeeditnext" : "function (eventdata)\n{\n    \n    return;\n    // this does not work, as the reload effect cancels editng.\n    var rec = _this.grid.ds.getAt(eventdata.cell[0]);\n    if (rec.data.coitem_subnumber *1 < 0 ) {\n        return;\n    }\n    var r = eventdata.cell[0] + 1;\n\n    while (true) {\n        if (r > _this.grid.ds.getCount()-1 ) {\n            eventdata.cell = false;\n            return;\n        }\n        rec =  _this.grid.ds.getAt(r);\n        if (rec.data.coitem_subnumber *1 < 0 ) {\n           eventdata.cell = [ r, eventdata.cell[1] ];\n           return;\n        }\n        r++;\n    }\n    \n    \n \n\n}"
1248          },
1249          "xtype" : "CellSelectionModel",
1250          "$ xns" : "Roo.grid",
1251          "* prop" : "sm",
1252          "enter_is_tab" : true
1253         },
1254         {
1255          "pageSize" : 100,
1256          "xtype" : "PagingToolbar",
1257          "emptyMsg" : "No Items",
1258          "$ xns" : "Roo",
1259          "displayInfo" : true,
1260          "$ updateSummary" : "function() {\n    var f = this;\n    new Pman.Request({\n        url : baseURL + '/Roo/Coitem',\n        method : 'GET',\n        params : {\n            _totals : 1,\n            coitem_cohead_id : _this.form.findField('cohead_id').getValue()\n        },\n        success : function(d) {\n            //Roo.log(d);\n            f.displayEl.update(String.format(\n                \"{0} items |  Subtotal: {2} | Tax: {3} | List Discount {4} | Total : {1}{5}\",\n                d.data.total_qty,\n                _this.form.findField('cohead_curr_id').el.dom.value,\n                d.data.total_sub,\n                d.data.total_tax,\n                d.data.total_list_discount,                \n                d.data.total_total\n            ));\n                \n        }\n    });\n}\n",
1261          "* prop" : "footer",
1262          "items" : [
1263           {
1264            "listeners" : {
1265             "click" : "function (_self, e)\n{\n    new Pman.Request({\n        url : baseURL + '/Roo/Cohead',\n        method : 'GET',\n        params : {\n            _fill_shipto : _this.form.findField('cohead_id').getValue()\n        },\n        success : function() {\n            _this.grid.footer.onClick('first');\n        }\n    });\n}"
1266            },
1267            "text" : "Fill empty Ship To",
1268            "xtype" : "Button",
1269            "$ xns" : "Roo.Toolbar"
1270           },
1271           {
1272            "listeners" : {
1273             "click" : "function (_self, e)\n{\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure?<BR>\"+\n        \"This will set all the locations to match the Sales Order - and remove all old locations.\",\n        function (res) {\n            if(res!='yes') {\n                return;\n            \n            }\n            new Pman.Request({\n                url : baseURL + '/Roo/Cohead',\n                method : 'GET',\n                params : {\n                    _fill_location : _this.form.findField('cohead_id').getValue(),\n                    _location_id : _this.form.findField('cohead_location_src').getValue()\n                },\n                success : function() {\n                    _this.grid.footer.onClick('first');\n                }\n            });\n    });\n    \n}"
1274            },
1275            "text" : "Update Location to match S/O",
1276            "xtype" : "Button",
1277            "$ xns" : "Roo.Toolbar"
1278           },
1279           {
1280            "listeners" : {
1281             "toggle" : "function (_self, pressed)\n{\n    this.setText(pressed ? \"Prices exc GST\" : \"Prices with GST\");\n    var cm = _this.grid.getColumnModel();\n\n    cm.setHidden(cm.getIndexByDataIndex('coitem_price_tax'), pressed ? false : true);\n    cm.setHidden(cm.getIndexByDataIndex('coitem_custprice_tax'), pressed ? false : true);\n    cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal_tax'), pressed ? false : true);\n    \n    cm.setHidden(cm.getIndexByDataIndex('coitem_price'), pressed ? true : false);\n    cm.setHidden(cm.getIndexByDataIndex('coitem_custprice'), pressed ? true : false);\n    cm.setHidden(cm.getIndexByDataIndex('coitem_subtotal'), pressed ? true : false);\n    return;\n}",
1282             "render" : "function (_self)\n{\n    _this.showgstBtn = _self;\n}"
1283            },
1284            "text" : "Prices with GST",
1285            "enableToggle" : true,
1286            "minWidth" : 100,
1287            "xtype" : "Button",
1288            "$ xns" : "Roo.Toolbar"
1289           }
1290          ]
1291         },
1292         {
1293          "listeners" : {
1294           "|beforeload" : "function (_self,o) {\n\n    try {\n       this.removeAll();\n   } catch (e) { }\n   \n\n    if (!_this.data || !_this.data.cohead_id) {\n        return false;\n    }\n    o.params = o.params || {};\n    \n    o.params.coitem_cohead_id = _this.data.cohead_id;\n    o.params._without_list_discount =1;\n    //o.params.limit = 999;\n\n    \n}",
1295           "update" : "function (_self, rec, operation)\n    {\n   \n   if (operation !=  Roo.data.Record.COMMIT) {\n       return;\n   }\n\n   // row has been updated..\n   // if the qty + item has been filled in, we should try and save it..\n \n    \n    var setRecord = function(){\n    \n         Roo.log(\"Clearing update?\"  + rec.data.coitem_linenumber);\n        rec.updatePending = 0;\n        if(rec.isInserting){\n            rec.isInserting = 0;\n            return;\n        }\n        rec.isUpdating = 0;\n\n    }\n    if (!(rec.data.coitem_itemsite_id * 1) || !(rec.data.coitem_qtyord*1)) {\n        setRecord();\n        return;\n    }\n    var     doCommit = function() {\n         Roo.log(\"Sending  data?\"  + rec.data.coitem_linenumber);\n        \n        new Pman.Request({\n            url : baseURL+'/Roo/coitem',\n            method : 'POST',\n            params : rec.data,\n            success: function(res)\n            {\n                try {\n                    var row = _this.grid.ds.indexOf(rec);\n                    Roo.get(_this.grid.view.getRow(row)).removeClass('dragon-not-saved');\n                } catch(e) {\n                    Roo.log(e);\n                }\n                    \n                \n                 Roo.log(\"GOT success: \"  + rec.data.coitem_linenumber);\n                //Roo.log(\"GOT success\");\n                // update the data...\n                \n                if (rec.data.item_type == 'K') {\n                     Roo.log(\"Kit??\");\n                    _this.grid.ds.load({});\n                    \n                    return;\n                }\n                \n                // why is this here.??\n                \n                if (_this.grid.activeEditor) {\n                     rec.editing = true;\n                     \n                     \n                 } \n                 \n                rec.set('coitem_id', res.data.coitem_id);\n                rec.set('coitem_status', res.data.coitem_status);\n                 \n                \n                rec.dirty = false;\n                delete rec.modified;\n                try {\n                    _this.grid.footer.updateSummary();          \n                    _this.grid.loadAvail();\n                } catch (e) { }\n                \n\n                setRecord();\n            },\n            failure : function(res)\n            {\n                setRecord();\n                Roo.MessageBox.alert(\"Error\", res.errorMsg ? res.errorMsg : \"Error updating\");\n            }\n            \n            \n        });\n      } ; \n   \n    \n    doCommit();\n    \n    \n    \n}\n   \n  ",
1296           "load" : "function (_self, records, options)\n{\n    // need to fetch availablity from master data..\n    // build a list of what to ask..\n\n    // query: ITEM CODE - LOCATION\n    _this.grid.footer.updateSummary();\n    _this.grid.loadAvail.defer(100, _this.grid);\n\n    \n    \n    \n}"
1297          },
1298          "xtype" : "Store",
1299          "remoteSort" : true,
1300          "$ sortInfo" : "{ field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' }",
1301          "$ xns" : "Roo.data",
1302          "* prop" : "dataSource",
1303          "items" : [
1304           {
1305            "$ url" : "baseURL + '/Roo/coitem.php'",
1306            "xtype" : "HttpProxy",
1307            "method" : "GET",
1308            "$ xns" : "Roo.data",
1309            "* prop" : "proxy"
1310           },
1311           {
1312            "id" : "coitem_id",
1313            "root" : "data",
1314            "xtype" : "JsonReader",
1315            "$ fields" : "[\n    {\n        'name': 'coitem_linenumber',\n        'type': 'int'\n    },\n    {\n        'name': 'coitem_itemsite_id',\n        'type': 'int'\n    },\n    {\n        'name': 'coitem_qtyord'\n    },\n    {\n        'name': 'coitem_unitcost'\n    },\n    {\n        'name': 'coitem_price'\n    },\n    {\n        'name': 'coitem_custprice'\n    },\n    {\n        'name': 'coitem_qtyreturned'\n    },\n    {\n        'name': 'coitem_prcost'\n    },\n    {\n        'name': 'coitem_price_uom_id',\n        'type': 'int'\n    },\n    {\n        'name': 'coitem_qtyreserved'\n    }\n]",
1316            "$ xns" : "Roo.data",
1317            "* prop" : "reader",
1318            "# builderCfg" : "{\"cols\":[{\"table\":\"coitem\",\"column\":\"coitem_linenumber\",\"columnshort\":\"coitem_linenumber\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Item#\"},{\"table\":\"coitem\",\"column\":\"coitem_itemsite_id\",\"columnshort\":\"coitem_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"itemsite_id\",\"deps\":[{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_item_id\",\"columnshort\":\"itemsite_item_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warehous_id\",\"columnshort\":\"itemsite_warehous_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_qtyonhand\",\"columnshort\":\"itemsite_qtyonhand\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_reorderlevel\",\"columnshort\":\"itemsite_reorderlevel\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordertoqty\",\"columnshort\":\"itemsite_ordertoqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cyclecountfreq\",\"columnshort\":\"itemsite_cyclecountfreq\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastcount\",\"columnshort\":\"itemsite_datelastcount\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastused\",\"columnshort\":\"itemsite_datelastused\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_loccntrl\",\"columnshort\":\"itemsite_loccntrl\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_safetystock\",\"columnshort\":\"itemsite_safetystock\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_minordqty\",\"columnshort\":\"itemsite_minordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_multordqty\",\"columnshort\":\"itemsite_multordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_leadtime\",\"columnshort\":\"itemsite_leadtime\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_abcclass\",\"columnshort\":\"itemsite_abcclass\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_issuemethod\",\"columnshort\":\"itemsite_issuemethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_controlmethod\",\"columnshort\":\"itemsite_controlmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_active\",\"columnshort\":\"itemsite_active\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_plancode_id\",\"columnshort\":\"itemsite_plancode_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costcat_id\",\"columnshort\":\"itemsite_costcat_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_eventfence\",\"columnshort\":\"itemsite_eventfence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_sold\",\"columnshort\":\"itemsite_sold\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_stocked\",\"columnshort\":\"itemsite_stocked\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_freeze\",\"columnshort\":\"itemsite_freeze\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_id\",\"columnshort\":\"itemsite_location_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparams\",\"columnshort\":\"itemsite_useparams\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparamsmanual\",\"columnshort\":\"itemsite_useparamsmanual\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_soldranking\",\"columnshort\":\"itemsite_soldranking\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createpr\",\"columnshort\":\"itemsite_createpr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location\",\"columnshort\":\"itemsite_location\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_comments\",\"columnshort\":\"itemsite_location_comments\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_notes\",\"columnshort\":\"itemsite_notes\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_perishable\",\"columnshort\":\"itemsite_perishable\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_nnqoh\",\"columnshort\":\"itemsite_nnqoh\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoabcclass\",\"columnshort\":\"itemsite_autoabcclass\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup\",\"columnshort\":\"itemsite_ordergroup\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_disallowblankwip\",\"columnshort\":\"itemsite_disallowblankwip\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_maxordqty\",\"columnshort\":\"itemsite_maxordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_mps_timefence\",\"columnshort\":\"itemsite_mps_timefence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createwo\",\"columnshort\":\"itemsite_createwo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warrpurc\",\"columnshort\":\"itemsite_warrpurc\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoreg\",\"columnshort\":\"itemsite_autoreg\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costmethod\",\"columnshort\":\"itemsite_costmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_value\",\"columnshort\":\"itemsite_value\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup_first\",\"columnshort\":\"itemsite_ordergroup_first\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_supply_itemsite_id\",\"columnshort\":\"itemsite_supply_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_planning_type\",\"columnshort\":\"itemsite_planning_type\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_wosupply\",\"columnshort\":\"itemsite_wosupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_posupply\",\"columnshort\":\"itemsite_posupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_lsseq_id\",\"columnshort\":\"itemsite_lsseq_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cosdefault\",\"columnshort\":\"itemsite_cosdefault\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopr\",\"columnshort\":\"itemsite_createsopr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopo\",\"columnshort\":\"itemsite_createsopo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_dropship\",\"columnshort\":\"itemsite_dropship\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyord\",\"columnshort\":\"coitem_qtyord\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Qty\"},{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"},{\"table\":\"coitem\",\"column\":\"coitem_price\",\"columnshort\":\"coitem_price\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Price\"},{\"table\":\"coitem\",\"column\":\"coitem_custprice\",\"columnshort\":\"coitem_custprice\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Cust Price\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyreturned\",\"columnshort\":\"coitem_qtyreturned\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#Returned\"},{\"table\":\"coitem\",\"column\":\"coitem_prcost\",\"columnshort\":\"coitem_prcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"prcost?\"},{\"table\":\"coitem\",\"column\":\"coitem_price_uom_id\",\"columnshort\":\"coitem_price_uom_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"uom_id\",\"deps\":[{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_name\",\"columnshort\":\"uom_name\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_descrip\",\"columnshort\":\"uom_descrip\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"uom\",\"column\":\"coitem_price_uom_id_uom_item_weight\",\"columnshort\":\"uom_item_weight\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"Unit of\"},{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}],\"cols_ex\":[\"coitem_price_uom_id_uom_descrip\"],\"table\":\"coitem\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
1319            "totalProperty" : "total"
1320           }
1321          ]
1322         },
1323         {
1324          "xtype" : "Toolbar",
1325          "$ xns" : "Roo",
1326          "* prop" : "toolbar",
1327          "items" : [
1328           {
1329            "listeners" : {
1330             "|click" : "function()\n{\n   \n    Roo.log(\"add presed\");\n     \n    // work out last \n    var grid = _this.grid;\n    var err = false;\n    grid.ds.each(function(r) {\n        if (r.data.coitem_qtyord < 1) { \n            Roo.MessageBox.alert(\"Error\", \"you must fill in a quantity for \" + r.data.item_number);\n            err = true;\n            return true;\n        }\n        \n    });\n    if (err) {\n        return;\n    }\n    \n\n//    var last = 0;\n    var last = _this.form.findField('cohead_max_linenumber').getValue();   \n    last++; \n    if(last == 99999){\n        last++;\n    }\n    \n\n    _this.form.findField('cohead_max_linenumber').setValue(last);    \n    \n    // this should be getting the previous row..??\n     var ct  =    _this.grid.ds.getCount();\n     var lastrow = ct ?  _this.grid.ds.getAt(ct-1)  : false;\n     \n     function lastor(k,d,kk) {\n        var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();\n        return lastrow ? lastrow.data[kk] : def;\n     }\n    \n    // uses form defaults or last row value.\n    var nr = _this.grid.ds.reader.newRow({\n        coitem_linenumber : last,\n        item_number : '',\n        item_descrip1 : '',\n        coitem_qtyord : 0,\n        coitem_cohead_id : _this.form.findField('cohead_id').getValue(),\n        coitem_qtyshipped : 0,\n        coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),\n        coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),\n        coitem_shipto_id    :  lastor('cohead_shipto_id',false, 'coitem_shipto_id'),\n        coitem_shipto_id_shipto_name  : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name'),\n        coitem_unitcost_in_order_cur  : 0,\n        coitem_taxtype_id : _this.data.default_taxtype_id,\n        coitem_taxtype_id_taxtype_name : 'Taxable',\n        coitem_status : '',\n        avail_qty : 0\n                \n    });\n    grid.stopEditing();\n    grid.ds.insert(grid.ds.getCount(), nr); \n    grid.startEditing(grid.ds.getCount()-1, 1); // type..\n    nr.updatePending = 0;\n    nr.isUpdating = 0;\n    nr.isInserting =0;\n    \n}\n",
1331             "render" : "function (_self)\n{\n    _this.addItemBtn = _self;\n}"
1332            },
1333            "text" : "Add",
1334            "xtype" : "Button",
1335            "cls" : "x-btn-text-icon",
1336            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
1337            "$ xns" : "Roo.Toolbar"
1338           },
1339           {
1340            "listeners" : {
1341             "click" : "function (_self, e)\n{\n    var last = _this.form.findField('cohead_max_linenumber').getValue();    \r\n    last++;\r\n    _this.form.findField('cohead_max_linenumber').setValue(last); \n\n    var ct  =    _this.grid.ds.getCount();\r\n    var lastrow = ct ?  _this.grid.ds.getAt(ct-1)  : false;\r\n         \r\n    function lastor(k,d,kk) {\r\n       var def = d ? _this.form.findField(k).el.dom.value : _this.form.findField(k).getValue();\r\n       return lastrow ? lastrow.data[kk] : def;\r\n    }\n    \n    var cohead_cust_id = _this.form.findField('cohead_cust_id').getValue();\n    var cohead_id = _this.form.findField('cohead_id').getValue();\n    \n    Pman.Dialog.XtupleSalesProductList.show( {cohead_cust_id : cohead_cust_id, cohead_id : cohead_id} , function(res) {\n\n        _this.grid.stopEditing();\n\n        if (_this.grid.ds.getCount() > 0) {\n            var lr = _this.grid.ds.getAt(_this.grid.ds.getCount()-1);\n            if (!lr.data.coitem_itemsite_id) {\n                lr.set('coitem_itemsite_id', res.item_itemsite_id_itemsite_id);\n                lr.set('item_number',  res.item_number);\n                lr.set('item_descrip1', res.item_descrip1);                                \n                lr.set('coitem_listprice', res.item_price);                \n                lr.set('coitem_price', res.item_price);                                \n                lr.set('coitem_custprice', res.item_price);                \n                return;\n            }\n        }\n        \n        \n        \n        var nr = _this.grid.ds.reader.newRow({\n            coitem_linenumber : last,\n            coitem_itemsite_id : res.item_itemsite_id_itemsite_id,\n            item_number : res.item_number,\n            item_descrip1 : res.item_descrip1,\n            coitem_qtyord : 0,\n            coitem_cohead_id : _this.form.findField('cohead_id').getValue(),\n            coitem_qtyshipped : 0,\n            coitem_listprice : res.item_price,\n            coitem_price : res.item_price,\n            coitem_custprice : res.item_price,\n            avail_qty : 0,\n            coitem_location_src : lastor('cohead_location_src',false, 'coitem_location_src'),\n            coitem_location_src_location_name : lastor('cohead_location_src',true, 'coitem_location_src_location_name'),\n            coitem_shipto_id    :  lastor('cohead_shipto_id',false, 'coitem_shipto_id'),\n            coitem_shipto_id_shipto_name  : lastor('cohead_shipto_id_shipto_name', false, 'coitem_shipto_id_shipto_name')\n                    \n        });\n        _this.grid.ds.insert(_this.grid.ds.getCount(), nr); \n\n   }); \n}"
1342            },
1343            "text" : "Find Products",
1344            "xtype" : "Button",
1345            "cls" : "x-btn-text-icon",
1346            "$ icon" : "rootURL + '/Pman/templates/images/search.gif'",
1347            "$ xns" : "Roo.Toolbar"
1348           },
1349           {
1350            "listeners" : {
1351             "|click" : "function()\n{\n    // work out last \n    new Pman.Request({\n        url : baseURL + '/Roo/coitem',\n        mask : 'Loading Data',\n        method: 'GET',\n        params : {\n\n            _hk_xfer :_this.form.findField('cohead_id').getValue()\n        },\n        success : function() {\n            _this.grid.ds.load({});\n        }\n    \n    });\n}\n",
1352             "render" : "function (_self)\n{\n    _this.xferAll  = _self;\n}"
1353            },
1354            "text" : "Xfer all stock to HK",
1355            "hidden" : true,
1356            "xtype" : "Button",
1357            "cls" : "x-btn-text-icon",
1358            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
1359            "$ xns" : "Roo.Toolbar"
1360           },
1361           {
1362            "listeners" : {
1363             "click" : "function (_self, e)\n{\n   var c    = _this.grid.getSelectionModel().getSelectedCell();\n   if (!c) {\n        Roo.MessageBox.alert(\"Error\", \"Select item to show history (you can also double click on the #avail number) \");\n        return;\n   }\n   \n    var rec = _this.grid.ds.getAt(c[0]);\n\n  Pman.Dialog.XtupleInvHistory.show({\n        itemsite_item_id_item_number   : rec.data.item_number,\n       // itemsite_item_id_item_descript1 : rec.data.item_descrip1,\n        location_name : rec.data.coitem_location_src_location_name,\n        location_descrip : rec.data.coitem_location_src_location_descrip,\n        \n        \n        invhist_transdate : _this.form.findField('cohead_targetdate').getValue() \n    }); \n    \n   \n}"
1364            },
1365            "text" : "Show Inventory History",
1366            "xtype" : "Button",
1367            "$ xns" : "Roo.Toolbar"
1368           },
1369           {
1370            "xtype" : "Separator",
1371            "$ xns" : "Roo.Toolbar"
1372           },
1373           {
1374            "text" : "Apply % Discount of : ",
1375            "xtype" : "TextItem",
1376            "$ xns" : "Roo.Toolbar"
1377           },
1378           {
1379            "listeners" : {
1380             "render" : "function (_self)\n{\n    _this._applyDiscount = _self;\n}"
1381            },
1382            "xtype" : "TextField",
1383            "$ xns" : "Roo.form",
1384            "width" : 40
1385           },
1386           {
1387            "listeners" : {
1388             "click" : "function (_self, e)\n{\n    var val =  parseFloat(_this._applyDiscount.getValue());\n    \n    var factor = (100.0 - val)/100.0;\n    \n    _this.grid.ds.each(function(rec) {\n        if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {\n            return;\n        }\n    \n        rec.set('coitem_price', rec.data.coitem_custprice * factor);\n        rec.set('coitem_linedisc', val);\n        rec.set('coitem_subtotal', rec.data.coitem_price  & rec.data.ordqty);\n        rec.commit();\n    \n    });\n    \n    \n}"
1389            },
1390            "text" : "Apply To All",
1391            "xtype" : "Button",
1392            "$ xns" : "Roo.Toolbar"
1393           },
1394           {
1395            "listeners" : {
1396             "click" : "function (_self, e)\n{\n\n    if (!(1* _this.form.findField('cohead_id').getValue())) {\n        Roo.MessageBox.alert(\"Error\", \"save the order first\");\n    }\n    \n\n   Pman.Dialog.Image.show(\n       {\n            timeout : 60000,\n            _url : baseURL+'/Xtuple/Import/SalesOrder',\n            onid : _this.form.findField('cohead_id').getValue()\n        \n       },\n       function (data) {\n\n            Roo.MessageBox.alert(\"Notice\", \"Uploaded\");\n            _this.grid.footer.onClick('first');\n\n       }\n   );\n}"
1397            },
1398            "text" : "Import",
1399            "xtype" : "Button",
1400            "$ xns" : "Roo.Toolbar"
1401           },
1402           {
1403            "xtype" : "Fill",
1404            "$ xns" : "Roo.Toolbar"
1405           },
1406           {
1407            "listeners" : {
1408             "|click" : "function()\n{\n     _this.grid.stopEditing();\n    // check that no shipments or invoices are done..\n    var rc = _this.grid.getSelectionModel().getSelectedCell();\n    \n    var rec = _this.grid.ds.getAt(rc[0]);\n    \n    if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {\n        Roo.MessageBox.alert(\"Error\", \"That item has been shipped or invoices - void the shipments/invoices first\");\n        return;\n    }\n   if (rec.data.coitem_subnumber*1  > 0) {\n        Roo.MessageBox.alert(\"Error\", \"Delete the kit item that that belongs to.\");\n        return;\n    }\n    if (!rec.data.coitem_id) {\n        _this.grid.ds.remove(rec);\n        return;\n    }\n    function remove()\n    {\n    \n        new  Pman.Request({\n            url : baseURL + '/Roo/coitem',\n            method : 'POST',\n            params : {\n                _delete : rec.data.coitem_id\n            \n            },\n            success : function() {\n                if (rec.data.item_type == 'K') {\n                    _this.grid.ds.load({});\n                    return;\n                }\n                _this.grid.ds.remove(rec);\n            }\n        \n        });\n    }\n    if (rec.data_qtyord * 1 < 1) {\n        remove();\n    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete that line?\", function(r)\n    {\n        if (r != 'yes') {\n            return;\n        }\n        remove();\n    \n    });\n\n    \n    \n}\n        "
1409            },
1410            "text" : "Delete",
1411            "xtype" : "Button",
1412            "cls" : "x-btn-text-icon",
1413            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
1414            "$ xns" : "Roo.Toolbar"
1415           },
1416           {
1417            "listeners" : {
1418             "|click" : "function()\n{\n     _this.grid.stopEditing();\n    // check that no shipments or invoices are done..\n    var ids = [];\n    _this.grid.ds.each(function(rec) {\n    \n\n    \n        if (rec.data.coitem_qtyshipped > 0 || rec.data.cobill_billed > 0) {\n            //Roo.MessageBox.alert(\"Error\", \"That item has been shipped or invoices - void the shipments/invoices first\");\n            return;\n        }\n        if (rec.data.item_type == 'K') {\n            return;\n        }\n\n       if (rec.data.coitem_subnumber*1  > 0) {\n            //Roo.MessageBox.alert(\"Error\", \"Delete the kit item that that belongs to.\");\n            return;\n        }\n        if (!rec.data.coitem_id) {\n            _this.grid.ds.remove(rec);\n            return;\n        }\n        ids.push(rec.data.coitem_id);\n    });\n    function remove()\n    {\n    \n        new  Pman.Request({\n            url : baseURL + '/Roo/coitem',\n            method : 'POST',\n            params : {\n                _delete : ids.join(',')\n            \n            },\n            success : function() {\n\n                _this.grid.footer.onClick('first');\n            }\n        \n        });\n    }\n//    if (rec.data_qtyord * 1 < 1) {\n//        remove();\n//    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete everything?\", function(r)\n    {\n        if (r != 'yes') {\n            return;\n        }\n        remove();\n    \n    });\n\n    \n    \n}\n        "
1419            },
1420            "text" : "Delete All",
1421            "xtype" : "Button",
1422            "cls" : "x-btn-text-icon",
1423            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
1424            "$ xns" : "Roo.Toolbar"
1425           }
1426          ]
1427         },
1428         {
1429          "xtype" : "ColumnModel",
1430          "header" : "Item#",
1431          "width" : 40,
1432          "$ renderer" : "function(v,x,r) {\n\n    if (r.data.coitem_subnumber * 1 > 0) {\n         return String.format('{0}.{1}', v,r.data.coitem_subnumber);\n     }\n     return String.format('{0}', v);\n  }",
1433          "$ xns" : "Roo.grid",
1434          "* prop" : "colModel[]",
1435          "dataIndex" : "coitem_linenumber",
1436          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_linenumber\",\"columnshort\":\"coitem_linenumber\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Item#\"}"
1437         },
1438         {
1439          "xtype" : "ColumnModel",
1440          "header" : "Item Code",
1441          "width" : 75,
1442          "$ renderer" : "function(v) { return String.format('{0}', v); }",
1443          "$ xns" : "Roo.grid",
1444          "* prop" : "colModel[]",
1445          "dataIndex" : "item_number",
1446          "items" : [
1447           {
1448            "xtype" : "GridEditor",
1449            "$ xns" : "Roo.grid",
1450            "* prop" : "editor",
1451            "items" : [
1452             {
1453              "listeners" : {
1454               "beforeselect" : "function (combo, record, index)\n{\n  // set _this.data values ..\n  var ar = _this.grid.activeEditor.record;\n//  Roo.log('beforeselect');\n  \n  \n  (function() { \n     //  Roo.log('beforeselect-cb');\n      ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);\n      ar.set('coitem_listprice', record.data.item_listprice);\n      ar.set('coitem_price', record.data.item_price);\n      ar.set('coitem_custprice', record.data.item_price);\n      ar.set('coitem_itemsite_id', record.data.itemsite_id);\n      ar.set('item_number', record.data.itemsite_item_id_item_number);\n     ar.set('item_type', record.data.itemsite_item_id_item_type);\n      ar.set('avail_qty', 0);\n      ar.commit();\n  }).defer(100);\n  \n}"
1455              },
1456              "listWidth" : 400,
1457              "triggerAction" : "all",
1458              "forceSelection" : true,
1459              "selectOnFocus" : true,
1460              "pageSize" : 20,
1461              "displayField" : "itemsite_item_id_item_number",
1462              "emptyText" : "Select item",
1463              "hiddenName" : "itemsite_item_id_item_number",
1464              "minChars" : 2,
1465              "valueField" : "item_number",
1466              "xtype" : "ComboBox",
1467              "allowBlank" : false,
1468              "typeAhead" : false,
1469              "editable" : true,
1470              "$ xns" : "Roo.form",
1471              "* prop" : "field",
1472              "name" : "item_number",
1473              "qtip" : "Select item",
1474              "queryParam" : "query[number]",
1475              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{itemsite_item_id_item_number}</b> ${item_price:toFixed(2)}- {itemsite_item_id_item_descrip1} </div>",
1476              "loadingText" : "Searching...",
1477              "items" : [
1478               {
1479                "listeners" : {
1480                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    o.params.customer_id = _this.form.findField('cohead_cust_id').getValue();\n    o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue();\n    //o.params.shipto_cust_id = _this.data.cohead_cust_id;\n    // set more here\n}\n"
1481                },
1482                "xtype" : "Store",
1483                "remoteSort" : true,
1484                "$ sortInfo" : "{ direction : 'ASC', field: 'item_number' }",
1485                "$ xns" : "Roo.data",
1486                "* prop" : "store",
1487                "items" : [
1488                 {
1489                  "$ url" : "baseURL + '/Roo/itemsite.php'",
1490                  "xtype" : "HttpProxy",
1491                  "method" : "GET",
1492                  "$ xns" : "Roo.data",
1493                  "* prop" : "proxy"
1494                 },
1495                 {
1496                  "id" : "shipto_id",
1497                  "root" : "data",
1498                  "xtype" : "JsonReader",
1499                  "$ fields" : "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]",
1500                  "$ xns" : "Roo.data",
1501                  "* prop" : "reader",
1502                  "totalProperty" : "total"
1503                 }
1504                ]
1505               }
1506              ]
1507             }
1508            ]
1509           }
1510          ]
1511         },
1512         {
1513          "xtype" : "ColumnModel",
1514          "header" : "From",
1515          "width" : 75,
1516          "$ renderer" : "function(v,x,r) { \n    return String.format('{0}', r.data.coitem_location_src_location_name); \n}",
1517          "$ xns" : "Roo.grid",
1518          "* prop" : "colModel[]",
1519          "dataIndex" : "coitem_location_src",
1520          "items" : [
1521           {
1522            "xtype" : "GridEditor",
1523            "$ xns" : "Roo.grid",
1524            "* prop" : "editor",
1525            "items" : [
1526             {
1527              "listeners" : {
1528               "beforeselect" : "function (combo, record, index)\n{\n  // set _this.data values ..\n  var ar = _this.grid.activeEditor.record;\n  \n  \n  \n  //Roo.log('beforeselect');\n \n /*\n  (function() { \n     //  Roo.log('beforeselect-cb');\n      ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);\n      ar.set('coitem_price', record.data.item_listprice);\n      ar.set('coitem_custprice', record.data.item_price);\n       ar.set('coitem_itemsite_id', record.data.itemsite_id);\n      ar.set('item_number', record.data.itemsite_item_id_item_number);\n\n      ar.commit();\n  }).defer(100);\n  */\n}"
1529              },
1530              "alwaysQuery" : true,
1531              "listWidth" : 400,
1532              "triggerAction" : "all",
1533              "forceSelection" : true,
1534              "selectOnFocus" : true,
1535              "pageSize" : 20,
1536              "displayField" : "location_name",
1537              "emptyText" : "Select location",
1538              "hiddenName" : "coitem_location_src",
1539              "minChars" : 2,
1540              "valueField" : "location_id",
1541              "xtype" : "ComboBox",
1542              "allowBlank" : false,
1543              "typeAhead" : false,
1544              "editable" : true,
1545              "$ xns" : "Roo.form",
1546              "* prop" : "field",
1547              "name" : "coitem_location_src_location_name",
1548              "qtip" : "Select item",
1549              "queryParam" : "query[location_name]",
1550              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b> {location_name}</b> {location_descrip}</div>",
1551              "loadingText" : "Searching...",
1552              "items" : [
1553               {
1554                "listeners" : {
1555                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    \n    var row = _this.grid.activeEditor.record;\n    \n    o.params['query[item_itemsite_id]'] = row.data.coitem_itemsite_id;\n    // need to know the date to calc the est. delivery time..\n    //o.params['query[avail_when]'] = _this.form.findField('cohead_targetdate').getValue().format('Y-m-d');\n    //o.params.location_netable = 1;\n    o.params['query[cohead_id]'] = _this.form.findField('cohead_id').getValue(); \n    \n     o.params.location_restrict = 0;\n    o.params._notinternalcompany = 1;\n    \n  //  _this.grid;\n\n//    o.params.itemsite_id = _this.form.findField('cohead_cust_id').getValue();\n    //o.params.shipto_cust_id = _this.data.cohead_cust_id;\n    // set more here\n}\n"
1556                },
1557                "xtype" : "Store",
1558                "remoteSort" : true,
1559                "$ sortInfo" : "{ direction : 'ASC', field: 'location_name' }",
1560                "$ xns" : "Roo.data",
1561                "* prop" : "store",
1562                "items" : [
1563                 {
1564                  "$ url" : "baseURL + '/Roo/location.php'",
1565                  "xtype" : "HttpProxy",
1566                  "method" : "GET",
1567                  "$ xns" : "Roo.data",
1568                  "* prop" : "proxy"
1569                 },
1570                 {
1571                  "id" : "shipto_id",
1572                  "root" : "data",
1573                  "xtype" : "JsonReader",
1574                  "$ fields" : "[{\"name\":\"location_id\",\"type\":\"int\"},\"location_name\"]",
1575                  "$ xns" : "Roo.data",
1576                  "* prop" : "reader",
1577                  "totalProperty" : "total"
1578                 }
1579                ]
1580               }
1581              ]
1582             }
1583            ]
1584           }
1585          ]
1586         },
1587         {
1588          "xtype" : "ColumnModel",
1589          "header" : "To",
1590          "width" : 75,
1591          "$ renderer" : "function(v,x,r) { \n    return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name); \n}",
1592          "$ xns" : "Roo.grid",
1593          "* prop" : "colModel[]",
1594          "dataIndex" : "coitem_shipto_id",
1595          "items" : [
1596           {
1597            "xtype" : "GridEditor",
1598            "$ xns" : "Roo.grid",
1599            "* prop" : "editor",
1600            "items" : [
1601             {
1602              "listeners" : {
1603               "add" : "function (combo)\n{\n\n   Pman.Dialog.XtupleCustomer.show({ cust_id : _this.form.findField('cohead_cust_id').getValue() }, function(data) {\n        // refresh the data in the pulldown..\n    }); \n}",
1604               "beforeselect" : "function (combo, record, index)\n{\n\n    var v = [];\n    for(var i = 1; i <4; i++) {\n        _this.data['cohead_shiptoaddress'+  i] = record.data['cntct_addr_id_addr_line'+i];\n    }\n    _this.form.findField('shipto_address').update();\n    \n \n}"
1605              },
1606              "alwaysQuery" : true,
1607              "listWidth" : 400,
1608              "triggerAction" : "all",
1609              "forceSelection" : true,
1610              "selectOnFocus" : true,
1611              "pageSize" : 20,
1612              "displayField" : "shipto_name",
1613              "emptyText" : "Select cntct",
1614              "hiddenName" : "cohead_shipto_id",
1615              "minChars" : 2,
1616              "valueField" : "shipto_id",
1617              "xtype" : "ComboBox",
1618              "allowBlank" : false,
1619              "typeAhead" : false,
1620              "editable" : false,
1621              "width" : 300,
1622              "$ xns" : "Roo.form",
1623              "* prop" : "field",
1624              "name" : "coitem_shipto_id_shipto_name",
1625              "qtip" : "Select shipto",
1626              "queryParam" : "query[shipto_name]",
1627              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>",
1628              "loadingText" : "Searching...",
1629              "items" : [
1630               {
1631                "listeners" : {
1632                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    o.params.shipto_cust_id = _this.data.cohead_cust_id; \n    //o.params['query[with_shipinfo]'] = 1;\n    // set more here\n}\n"
1633                },
1634                "xtype" : "Store",
1635                "remoteSort" : true,
1636                "$ sortInfo" : "{ direction : 'ASC', field: 'shipto_name' }",
1637                "$ xns" : "Roo.data",
1638                "* prop" : "store",
1639                "items" : [
1640                 {
1641                  "$ url" : "baseURL + '/Roo/shiptoinfo.php'",
1642                  "xtype" : "HttpProxy",
1643                  "method" : "GET",
1644                  "$ xns" : "Roo.data",
1645                  "* prop" : "proxy"
1646                 },
1647                 {
1648                  "id" : "shipto_id",
1649                  "root" : "data",
1650                  "xtype" : "JsonReader",
1651                  "$ fields" : "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]",
1652                  "$ xns" : "Roo.data",
1653                  "* prop" : "reader",
1654                  "totalProperty" : "total"
1655                 }
1656                ]
1657               }
1658              ]
1659             }
1660            ]
1661           }
1662          ]
1663         },
1664         {
1665          "xtype" : "ColumnModel",
1666          "header" : "Item Description",
1667          "width" : 150,
1668          "$ renderer" : "function(v,x,r) { \n\n    if (r.data.coitem_memo && r.data.coitem_memo.length) {\n        return String.format('{0}', r.data.coitem_memo);\n        if (r.data.coitem_memo != v) {\n            r.set('item_descrip1', r.data.coitem_memo);\n        }\n        \n    }\n    if (v && v.length > 49) {\n        return String.format('<span style=\"color:orange\" qtip=\"line may be too long to print\">{0}</span>', v);\n    }\n    \n    return String.format('{0}', v); \n    \n}",
1669          "$ xns" : "Roo.grid",
1670          "* prop" : "colModel[]",
1671          "dataIndex" : "item_descrip1",
1672          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_itemsite_id\",\"columnshort\":\"coitem_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"itemsite_id\",\"deps\":[{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_item_id\",\"columnshort\":\"itemsite_item_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warehous_id\",\"columnshort\":\"itemsite_warehous_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_qtyonhand\",\"columnshort\":\"itemsite_qtyonhand\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_reorderlevel\",\"columnshort\":\"itemsite_reorderlevel\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordertoqty\",\"columnshort\":\"itemsite_ordertoqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cyclecountfreq\",\"columnshort\":\"itemsite_cyclecountfreq\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastcount\",\"columnshort\":\"itemsite_datelastcount\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_datelastused\",\"columnshort\":\"itemsite_datelastused\",\"ctype\":\"date\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_loccntrl\",\"columnshort\":\"itemsite_loccntrl\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_safetystock\",\"columnshort\":\"itemsite_safetystock\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_minordqty\",\"columnshort\":\"itemsite_minordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_multordqty\",\"columnshort\":\"itemsite_multordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_leadtime\",\"columnshort\":\"itemsite_leadtime\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_abcclass\",\"columnshort\":\"itemsite_abcclass\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_issuemethod\",\"columnshort\":\"itemsite_issuemethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_controlmethod\",\"columnshort\":\"itemsite_controlmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_active\",\"columnshort\":\"itemsite_active\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_plancode_id\",\"columnshort\":\"itemsite_plancode_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costcat_id\",\"columnshort\":\"itemsite_costcat_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_eventfence\",\"columnshort\":\"itemsite_eventfence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_sold\",\"columnshort\":\"itemsite_sold\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_stocked\",\"columnshort\":\"itemsite_stocked\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_freeze\",\"columnshort\":\"itemsite_freeze\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_id\",\"columnshort\":\"itemsite_location_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparams\",\"columnshort\":\"itemsite_useparams\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_useparamsmanual\",\"columnshort\":\"itemsite_useparamsmanual\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_soldranking\",\"columnshort\":\"itemsite_soldranking\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createpr\",\"columnshort\":\"itemsite_createpr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location\",\"columnshort\":\"itemsite_location\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_location_comments\",\"columnshort\":\"itemsite_location_comments\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_notes\",\"columnshort\":\"itemsite_notes\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_perishable\",\"columnshort\":\"itemsite_perishable\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_nnqoh\",\"columnshort\":\"itemsite_nnqoh\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoabcclass\",\"columnshort\":\"itemsite_autoabcclass\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup\",\"columnshort\":\"itemsite_ordergroup\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_disallowblankwip\",\"columnshort\":\"itemsite_disallowblankwip\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_maxordqty\",\"columnshort\":\"itemsite_maxordqty\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_mps_timefence\",\"columnshort\":\"itemsite_mps_timefence\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createwo\",\"columnshort\":\"itemsite_createwo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_warrpurc\",\"columnshort\":\"itemsite_warrpurc\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_autoreg\",\"columnshort\":\"itemsite_autoreg\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_costmethod\",\"columnshort\":\"itemsite_costmethod\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_value\",\"columnshort\":\"itemsite_value\",\"ctype\":\"numeric\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_ordergroup_first\",\"columnshort\":\"itemsite_ordergroup_first\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_supply_itemsite_id\",\"columnshort\":\"itemsite_supply_itemsite_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_planning_type\",\"columnshort\":\"itemsite_planning_type\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_wosupply\",\"columnshort\":\"itemsite_wosupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_posupply\",\"columnshort\":\"itemsite_posupply\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_lsseq_id\",\"columnshort\":\"itemsite_lsseq_id\",\"ctype\":\"int4\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_cosdefault\",\"columnshort\":\"itemsite_cosdefault\",\"ctype\":\"bpchar\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopr\",\"columnshort\":\"itemsite_createsopr\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_createsopo\",\"columnshort\":\"itemsite_createsopo\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"itemsite\",\"column\":\"coitem_itemsite_id_itemsite_dropship\",\"columnshort\":\"itemsite_dropship\",\"ctype\":\"bool\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
1673          "items" : [
1674           {
1675            "xtype" : "GridEditor",
1676            "$ xns" : "Roo.grid",
1677            "* prop" : "editor",
1678            "items" : [
1679             {
1680              "xtype" : "TextField",
1681              "allowBlank" : false,
1682              "$ xns" : "Roo.form",
1683              "* prop" : "field"
1684             }
1685            ]
1686           }
1687          ]
1688         },
1689         {
1690          "align" : "right",
1691          "xtype" : "ColumnModel",
1692          "header" : "Status",
1693          "width" : 50,
1694          "$ renderer" : "function(v) { return String.format('{0}', v); }",
1695          "$ xns" : "Roo.grid",
1696          "* prop" : "colModel[]",
1697          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}",
1698          "dataIndex" : "coitem_status"
1699         },
1700         {
1701          "align" : "right",
1702          "xtype" : "ColumnModel",
1703          "header" : "Qty",
1704          "width" : 40,
1705          "$ renderer" : "function(v,x,r) { \n    var v = parseInt(v);\n    //var aq = parseInt(r.data.avail_qty);\n    //aq = isNaN(aq) ? 0 : aq;\n   \n    var rate = _this.form.findField('taxzone_rate').getValue();\n    r.data.coitem_subtotal =  v * r.data.coitem_price;\n    r.data.coitem_subtotal_tax = v * r.data.coitem_price * ( 1 + rate * 1);\n    return String.format('{0}', v); \n    \n}",
1706          "$ xns" : "Roo.grid",
1707          "* prop" : "colModel[]",
1708          "dataIndex" : "coitem_qtyord",
1709          "items" : [
1710           {
1711            "xtype" : "GridEditor",
1712            "$ xns" : "Roo.grid",
1713            "* prop" : "editor",
1714            "items" : [
1715             {
1716              "listeners" : {
1717               "focus" : "function (_self)\n{\n    if (this.value == 0) {\n        this.el.dom.value = '';\n    }\n}"
1718              },
1719              "minValue" : 1,
1720              "style" : "text-align:right",
1721              "xtype" : "NumberField",
1722              "allowDecimals" : false,
1723              "decimalPrecision" : 0,
1724              "$ xns" : "Roo.form",
1725              "* prop" : "field"
1726             }
1727            ]
1728           }
1729          ]
1730         },
1731         {
1732          "align" : "right",
1733          "xtype" : "ColumnModel",
1734          "header" : "Sell @",
1735          "width" : 70,
1736          "$ renderer" : "function(v,x,r) { \n\n    var rate = _this.form.findField('taxzone_rate').getValue();\n    r.data.coitem_subtotal = v * r.data.coitem_qtyord;\n    r.data.coitem_subtotal_tax = v * ( 1 + rate * 1 ) * r.data.coitem_qtyord;\n    r.data.coitem_price_tax = v * ( 1 + rate * 1 );\n    if (parseInt(v) < 1) {\n        return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(v,3)); \n    }\n    \n    \n    //r.set('coitem_subtotal', v * r.data.coitem_qtyord);\n    \n    return  String.format('{0}', Roo.util.Format.number(v,3)); \n}",
1737          "$ xns" : "Roo.grid",
1738          "* prop" : "colModel[]",
1739          "dataIndex" : "coitem_price",
1740          "items" : [
1741           {
1742            "xtype" : "GridEditor",
1743            "$ xns" : "Roo.grid",
1744            "* prop" : "editor",
1745            "items" : [
1746             {
1747              "listeners" : {
1748               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1749              },
1750              "minValue" : 0,
1751              "style" : "text-align:right",
1752              "xtype" : "NumberField",
1753              "decimalPrecision" : 3,
1754              "$ xns" : "Roo.form",
1755              "* prop" : "field"
1756             }
1757            ]
1758           }
1759          ]
1760         },
1761         {
1762          "align" : "right",
1763          "hidden" : true,
1764          "xtype" : "ColumnModel",
1765          "header" : "Sell @w/GST",
1766          "width" : 70,
1767          "$ renderer" : "function(v,x,r) { \n    \n    if (parseInt(v) < 1) {\n        return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(v,3)); \n    }\n    \n    return  String.format('{0}', Roo.util.Format.number(v,3)); \n}",
1768          "$ xns" : "Roo.grid",
1769          "* prop" : "colModel[]",
1770          "dataIndex" : "coitem_price_tax",
1771          "items" : [
1772           {
1773            "xtype" : "GridEditor",
1774            "$ xns" : "Roo.grid",
1775            "* prop" : "editor",
1776            "items" : [
1777             {
1778              "listeners" : {
1779               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1780              },
1781              "minValue" : 0,
1782              "style" : "text-align:right",
1783              "xtype" : "NumberField",
1784              "decimalPrecision" : 3,
1785              "$ xns" : "Roo.form",
1786              "* prop" : "field"
1787             }
1788            ]
1789           }
1790          ]
1791         },
1792         {
1793          "align" : "right",
1794          "xtype" : "ColumnModel",
1795          "header" : "Disc%",
1796          "width" : 50,
1797          "$ renderer" : "function(v,x,r) { \n\n    // coitem_custprice = coitem_price * ((100 - coitem_disc)/ 100) \n    \n    //                      12 * (( 100 - 0) / 100)\n    // coitem_custprice / coitem_price = ((100 - coitem_disc)/ 100) \n    // 100 - ((coitem_custprice / coitem_price) * 100)  = coitem_disc\n    //                             100 -  97 =        100 -3 \n\n   // r.data.coitem_linedisc = 100 - (\n    //           (parseFloat(r.data.coitem_custprice) /\n     //               parseFloat(r.data.coitem_price)\n       //        ) * 100.00);\n    var fl = parseFloat(r.data.coitem_linedisc);\n    if ( isNaN(fl) || fl == 0.0 || r.data.coitem_price > r.data.coitem_custprice)  {\n        return '';\n    }\n    return  String.format('<span style=\"color:green\">{0}%</span>', Roo.util.Format.number( r.data.coitem_linedisc,2)); \n}",
1798          "$ xns" : "Roo.grid",
1799          "* prop" : "colModel[]",
1800          "dataIndex" : "coitem_linedisc",
1801          "items" : [
1802           {
1803            "xtype" : "GridEditor",
1804            "$ xns" : "Roo.grid",
1805            "* prop" : "editor",
1806            "items" : [
1807             {
1808              "listeners" : {
1809               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1810              },
1811              "minValue" : 0,
1812              "style" : "text-align:right",
1813              "xtype" : "NumberField",
1814              "decimalPrecision" : 2,
1815              "$ xns" : "Roo.form",
1816              "maxValue" : 100,
1817              "* prop" : "field"
1818             }
1819            ]
1820           }
1821          ]
1822         },
1823         {
1824          "align" : "right",
1825          "xtype" : "ColumnModel",
1826          "header" : "List Price",
1827          "width" : 70,
1828          "$ renderer" : "function(v,x,r) { \n    \n    var rate = _this.form.findField('taxzone_rate').getValue();\n    r.data.coitem_custprice_tax = v * ( 1 + rate * 1 );\n    \n    var tip = 'No WRP available';\n    if ((r.data.coitem_wrpprice * 1) > 0) {\n        tip = \"WRP : \" + Roo.util.Format.number(r.data.coitem_wrpprice,3);\n    }\n    // less than zero, show as red..\n    if (parseFloat(v) < 1) {\n        return String.format('<b qtip=\"{1}\" style=\"color:red;\">{0}</b>', \n            Roo.util.Format.number(v,3), tip); \n    }\n    if (r.data.customer_price_each != v) {\n          return String.format('<b qtip=\"{1}\" style=\"color:pink;\">{0}</b>', \n            Roo.util.Format.number(v,3), \n            \"List Price = \" +  Roo.util.Format.number(r.data.customer_price_each,3)\n        ); \n    }\n    \n    \n    \n    //r.data.coitem_subtotal = v * r.data.coitem_qtyord;\n    \n    //r.set('coitem_subtotal', v * r.data.coitem_qtyord);\n    \n    return  String.format('<span qtip=\"{1}\">{0}</span>', Roo.util.Format.number(v,3), tip); \n}",
1829          "$ xns" : "Roo.grid",
1830          "* prop" : "colModel[]",
1831          "dataIndex" : "coitem_custprice",
1832          "items" : [
1833           {
1834            "xtype" : "GridEditor",
1835            "$ xns" : "Roo.grid",
1836            "* prop" : "editor",
1837            "items" : [
1838             {
1839              "listeners" : {
1840               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1841              },
1842              "minValue" : 0,
1843              "style" : "text-align:right",
1844              "xtype" : "NumberField",
1845              "decimalPrecision" : 3,
1846              "$ xns" : "Roo.form",
1847              "* prop" : "field"
1848             }
1849            ]
1850           }
1851          ]
1852         },
1853         {
1854          "align" : "right",
1855          "hidden" : true,
1856          "xtype" : "ColumnModel",
1857          "header" : "List Price w/GST",
1858          "width" : 70,
1859          "$ renderer" : "function(v,x,r) { \n    var rate = _this.form.findField('taxzone_rate').getValue();\n    var tip = 'No WRP available';\n    if ((r.data.coitem_wrpprice * 1) > 0) {\n        tip = \"WRP : \" + Roo.util.Format.number(r.data.coitem_wrpprice,3);\n    }\n    \n    if (parseFloat(v) < 1) {\n        return String.format('<b qtip=\"{1}\" style=\"color:red;\">{0}</b>', \n            Roo.util.Format.number(v,3), tip); \n    }\n    if (r.data.customer_price_each != v) {\n          return String.format('<b qtip=\"{1}\" style=\"color:pink;\">{0}</b>', \n            Roo.util.Format.number(v,3), \n            \"List Price = \" +  Roo.util.Format.number(r.data.customer_price_each * ( 1 + rate * 1 ),3)\n        ); \n    }\n    \n    return  String.format('<span qtip=\"{1}\">{0}</span>', Roo.util.Format.number(v,3), tip); \n}",
1860          "$ xns" : "Roo.grid",
1861          "* prop" : "colModel[]",
1862          "dataIndex" : "coitem_custprice_tax",
1863          "items" : [
1864           {
1865            "xtype" : "GridEditor",
1866            "$ xns" : "Roo.grid",
1867            "* prop" : "editor",
1868            "items" : [
1869             {
1870              "listeners" : {
1871               "focus" : "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1872              },
1873              "minValue" : 0,
1874              "style" : "text-align:right",
1875              "xtype" : "NumberField",
1876              "decimalPrecision" : 3,
1877              "$ xns" : "Roo.form",
1878              "* prop" : "field"
1879             }
1880            ]
1881           }
1882          ]
1883         },
1884         {
1885          "align" : "right",
1886          "xtype" : "ColumnModel",
1887          "header" : "SubTotal",
1888          "width" : 70,
1889          "$ renderer" : "function(v) {\n\n    if (parseInt(v) < 1) {\n        return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(v,2)); \n    }\n\n    \n\n return Roo.util.Format.number( v, 2);\n  }",
1890          "$ xns" : "Roo.grid",
1891          "* prop" : "colModel[]",
1892          "dataIndex" : "coitem_subtotal"
1893         },
1894         {
1895          "align" : "right",
1896          "hidden" : true,
1897          "xtype" : "ColumnModel",
1898          "header" : "SubTotal w/GST",
1899          "width" : 70,
1900          "$ renderer" : "function(v,x,r) { \n   \n    if (parseInt(v) < 1) {\n        return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(v,2)); \n    }\n    \n    return  String.format('{0}', Roo.util.Format.number(v,2)); \n}",
1901          "$ xns" : "Roo.grid",
1902          "* prop" : "colModel[]",
1903          "dataIndex" : "coitem_subtotal_tax"
1904         },
1905         {
1906          "align" : "right",
1907          "xtype" : "ColumnModel",
1908          "header" : "Unit Cost",
1909          "width" : 50,
1910          "$ renderer" : "function(v) { return Roo.util.Format.number( v, 2); }",
1911          "$ xns" : "Roo.grid",
1912          "* prop" : "colModel[]",
1913          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}",
1914          "dataIndex" : "coitem_unitcost_in_order_cur"
1915         },
1916         {
1917          "align" : "right",
1918          "xtype" : "ColumnModel",
1919          "header" : "Taxed",
1920          "width" : 50,
1921          "$ renderer" : "function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); }",
1922          "$ xns" : "Roo.grid",
1923          "* prop" : "colModel[]",
1924          "dataIndex" : "coitem_taxtype_id",
1925          "items" : [
1926           {
1927            "xtype" : "GridEditor",
1928            "$ xns" : "Roo.grid",
1929            "* prop" : "editor",
1930            "items" : [
1931             {
1932              "listWidth" : 400,
1933              "triggerAction" : "all",
1934              "forceSelection" : true,
1935              "selectOnFocus" : true,
1936              "pageSize" : 20,
1937              "displayField" : "taxtype_name",
1938              "emptyText" : "Select Tax Type",
1939              "hiddenName" : "coitem_taxtype_id",
1940              "minChars" : 2,
1941              "valueField" : "taxtype_id",
1942              "xtype" : "ComboBox",
1943              "allowBlank" : false,
1944              "typeAhead" : true,
1945              "editable" : false,
1946              "width" : 40,
1947              "$ xns" : "Roo.form",
1948              "* prop" : "field",
1949              "name" : "coitem_taxtype_id_taxtype_name",
1950              "qtip" : "Select taxtype",
1951              "queryParam" : "query[taxtype_id]",
1952              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{taxtype_name}</b> </div>",
1953              "loadingText" : "Searching...",
1954              "items" : [
1955               {
1956                "listeners" : {
1957                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    \n    \n}\n"
1958                },
1959                "xtype" : "Store",
1960                "remoteSort" : true,
1961                "$ sortInfo" : "{ direction : 'ASC', field: 'taxtype_name' }",
1962                "$ xns" : "Roo.data",
1963                "* prop" : "store",
1964                "items" : [
1965                 {
1966                  "$ url" : "baseURL + '/Roo/taxtype.php'",
1967                  "xtype" : "HttpProxy",
1968                  "method" : "GET",
1969                  "$ xns" : "Roo.data",
1970                  "* prop" : "proxy"
1971                 },
1972                 {
1973                  "id" : "taxtype_id",
1974                  "root" : "data",
1975                  "xtype" : "JsonReader",
1976                  "$ fields" : "[{\"name\":\"taxtype_id\",\"type\":\"int\"},\"taxtype_name\"]",
1977                  "$ xns" : "Roo.data",
1978                  "* prop" : "reader",
1979                  "totalProperty" : "total"
1980                 }
1981                ]
1982               }
1983              ]
1984             }
1985            ]
1986           }
1987          ]
1988         },
1989         {
1990          "align" : "right",
1991          "xtype" : "ColumnModel",
1992          "header" : "#avail",
1993          "width" : 50,
1994          "$ renderer" : "function(v,x,r) { \n\n    var oq  = parseInt(r.data.coitem_qtyord);\n    var aq = parseInt(r.data.avail_qty);\n    var sq = parseInt(r.data.coitem_qtyshipped);\n    aq = isNaN(aq) ? 0 : aq;\n    oq = isNaN(oq) ? 0 : oq;\n    sq = isNaN(sq) ? 0 : sq;\n    \n    var unshipped = oq - sq;\n    \n    if ( aq < 0 || (unshipped > 0  &&  aq < unshipped))  {\n       return String.format('<b style=\"color:red;\">{0}</b>', parseInt(aq));\n    }\n     \n    return String.format('{0}', aq); \n    \n}",
1995          "$ xns" : "Roo.grid",
1996          "* prop" : "colModel[]",
1997          "dataIndex" : "avail_qty"
1998         },
1999         {
2000          "align" : "right",
2001          "xtype" : "ColumnModel",
2002          "header" : "#reserved",
2003          "width" : 50,
2004          "$ renderer" : "function(v,x,r) { \n\n    \n    var vv = parseInt(v);\n    vv = isNaN(vv) ? 0 : vv;\n    \n    var ov = parseInt(r.data.coitem_qtyord);\n    ov = isNaN(ov) ? 0 : ov;\n    \n    var qs = parseInt(r.data.coitem_qtyshipped);\n    qs = isNaN(qs) ? 0 : qs;\n    \n    \n    \n    if (vv < ov) {\n        // not enough reserved yet.\n        return String.format('<b style=\"background-color:red;color:yellow\">{0}</b>', vv - qs);\n    }\n    \n    return String.format('{0}', vv -  qs); \n    \n}",
2005          "$ xns" : "Roo.grid",
2006          "* prop" : "colModel[]",
2007          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}",
2008          "dataIndex" : "shipitem_shipped"
2009         },
2010         {
2011          "align" : "right",
2012          "xtype" : "ColumnModel",
2013          "header" : "#shipped",
2014          "width" : 50,
2015          "$ renderer" : "function(v,x,r) { \n    \n    var vv = parseInt(v);\n    vv = isNaN(vv) ? 0 : vv;\n    \n    var ov = parseInt(r.data.coitem_qtyord);\n    ov = isNaN(ov) ? 0 : ov;\n    \n\n    if (vv != ov) {\n        // not enought shipped.\n        // or too many shipped.\n        return String.format('<b style=\"background-color:red;color:yellow\">{0}</b>',  vv);\n    }\n\n    \n    \n    return String.format('{0}', vv); \n    \n}",
2016          "$ xns" : "Roo.grid",
2017          "* prop" : "colModel[]",
2018          "# builderCfg" : "{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}",
2019          "dataIndex" : "coitem_qtyshipped"
2020         },
2021         {
2022          "align" : "right",
2023          "xtype" : "ColumnModel",
2024          "header" : "#invoiced",
2025          "width" : 50,
2026          "$ renderer" : "function(v,x,r) { \n    \n    var vv = parseInt(v);\n    vv = isNaN(vv) ? 0 : vv;\n    \n    var ov = parseInt(r.data.coitem_qtyord);\n    ov = isNaN(ov) ? 0 : ov;\n    \n\n    if (vv !=ov) {\n            return String.format('<b style=\"background-color:red;color:yellow\">{0}</b>', vv); \n    }\n    return String.format('{0}', vv); \n    \n}",
2027          "$ xns" : "Roo.grid",
2028          "* prop" : "colModel[]",
2029          "dataIndex" : "cobill_billed"
2030         }
2031        ]
2032       }
2033      ]
2034     },
2035     {
2036      "listeners" : {
2037       "activate" : "function (_self)\n{\n    _this.shipinvtab = _self;\n}"
2038      },
2039      "region" : "center",
2040      "xtype" : "NestedLayoutPanel",
2041      "title" : "Shipments / Invoices",
2042      "$ xns" : "Roo",
2043      "items" : [
2044       {
2045        "xtype" : "BorderLayout",
2046        "$ xns" : "Roo",
2047        "* prop" : "layout",
2048        "items" : [
2049         {
2050          "xtype" : "LayoutRegion",
2051          "$ xns" : "Roo",
2052          "* prop" : "center",
2053          "titlebar" : true
2054         },
2055         {
2056          "title" : "Reserve Stock / Shipments",
2057          "xtype" : "LayoutRegion",
2058          "$ xns" : "Roo",
2059          "* prop" : "north",
2060          "height" : 250
2061         },
2062         {
2063          "listeners" : {
2064           "|activate" : "function() {\n    _this.shippanel = this;\n    if (_this.shipgrid) {\n        _this.shipgrid.ds.load({});\n    }\n}"
2065          },
2066          "fitToframe" : true,
2067          "region" : "north",
2068          "background" : false,
2069          "title" : "shiphead",
2070          "xtype" : "GridPanel",
2071          "fitContainer" : true,
2072          "$ xns" : "Roo",
2073          "# builderCfg" : "{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2074          "tableName" : "shiphead",
2075          "items" : [
2076           {
2077            "listeners" : {
2078             "rowdblclick" : "function (_self, rowIndex, e)\n{\n    var rec = this.ds.getAt(rowIndex);\n    if (!rec.json.shiphead_shipdate.length) {\n         Roo.MessageBox.alert(\"Error\", \"You can not edit voided shipments, create a new one, and use the restore feature\");\n         return;\n     }\n\n   Pman.Dialog.XtupleShipment.show({\n        shiphead_id : rec.data.shiphead_id\n\n    }, function() {\n        _self.ds.load({});\n    \n    });\n   \n}\n",
2079             "|render" : "function() \n{\n    _this.shipgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.shippanel.active) {\n       this.ds.load({});\n    }\n}"
2080            },
2081            "autoExpandColumn" : "shiphead_shipvia",
2082            "xtype" : "Grid",
2083            "loadMask" : true,
2084            "$ xns" : "Roo.grid",
2085            "* prop" : "grid",
2086            "# builderCfg" : "{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2087            "items" : [
2088             {
2089              "xtype" : "RowSelectionModel",
2090              "singleSelect" : true,
2091              "$ xns" : "Roo.grid",
2092              "* prop" : "sm"
2093             },
2094             {
2095              "listeners" : {
2096               "beforeload" : "function (_self, options)\n{\n     options.params = options.params || {};\n     options.params.shiphead_order_id = _this.form.findField('cohead_id').getValue() * 1;\n    if (options.params.shiphead_order_id < 1) {\n        return false;\n    }\n}"
2097              },
2098              "remoteSort" : true,
2099              "xtype" : "Store",
2100              "$ sortInfo" : "{ field : 'shiphead_shipvia', direction: 'ASC' }",
2101              "$ xns" : "Roo.data",
2102              "* prop" : "dataSource",
2103              "# builderCfg" : "{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2104              "items" : [
2105               {
2106                "$ url" : "baseURL + '/Roo/shiphead.php'",
2107                "method" : "GET",
2108                "xtype" : "HttpProxy",
2109                "$ xns" : "Roo.data",
2110                "* prop" : "proxy"
2111               },
2112               {
2113                "id" : "id",
2114                "root" : "data",
2115                "xtype" : "JsonReader",
2116                "$ xns" : "Roo.data",
2117                "$ fields" : "[\n    {\n        'name': 'shiphead_number',\n        'type': 'string'\n    },\n    {\n        'name': 'shiphead_shipvia',\n        'type': 'string'\n    },\n    {\n        'name': 'shiphead_shipdate',\n        'type': 'date'\n    },\n    {\n        'name': 'shiphead_sfstatus'\n    },\n    {\n        'name': 'shiphead_tracknum',\n        'type': 'string'\n    }\n]",
2118                "* prop" : "reader",
2119                "totalProperty" : "total",
2120                "# builderCfg" : "{\"cols\":[{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"shiphead_shipvia\"],\"table\":\"shiphead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}"
2121               }
2122              ]
2123             },
2124             {
2125              "xtype" : "Toolbar",
2126              "$ xns" : "Roo",
2127              "* prop" : "toolbar",
2128              "items" : [
2129               {
2130                "listeners" : {
2131                 "|click" : "function()\n{\n     var sel  = _this.shipgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a shipment\");\n        return;\n    }\n    if (sel.data.shiphead_shipped) {\n        Roo.MessageBox.alert(\"Error\", \"Shipment is already confirmed\");\n        return;\n    }\n    \n    \n    // check current status of shipment..\n    \n        \n    new Pman.Request({ \n           mask : 'Sending',\n        url : baseURL + '/Roo/shiphead',\n        method : 'POST',\n        timeout : 90000,\n        params : {\n            shiphead_id : sel.data.shiphead_id,\n            _confirm : 1\n        },\n        success : function() {\n            _this.shipgrid.ds.load({});\n        }\n    });\n         \n     \n}"
2132                },
2133                "text" : "Confirm Shipment",
2134                "xtype" : "Button",
2135                "cls" : "x-btn-text-icon",
2136                "$ icon" : "rootURL + '/Pman/templates/images/lock.gif'",
2137                "$ xns" : "Roo.Toolbar"
2138               },
2139               {
2140                "listeners" : {
2141                 "|click" : "function()\n{\n     var sel  = _this.shipgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a shipment\");\n        return;\n    }\n\n    \n    // check current status of shipment..\n    \n        \n   new Pman.Download({\n        url : baseURL + '/Roo/shiphead',\n        method : 'GET',\n        params : {\n           _download :sel.data.shiphead_id\n             \n        }\n    });\n         \n     \n}"
2142                },
2143                "text" : "Download (as xls)",
2144                "xtype" : "Button",
2145                "cls" : "x-btn-text-icon",
2146                "$ icon" : "rootURL + '/Pman/templates/images/save.gif'",
2147                "$ xns" : "Roo.Toolbar"
2148               },
2149               {
2150                "listeners" : {
2151                 "click" : "function ()\n{\n    var sel  = _this.shipgrid.getSelectionModel().getSelected();\r\n    if (!sel) {\r\n        Roo.MessageBox.alert(\"Error\", \"Select a shipment\");\r\n        return;\r\n    }\r\n    // check current status of shipment..\n \n        new Pman.Download({\n            url : baseURL + '/Xtuple/Print',\n            method : 'GET',\n            params : {\n                template : 'picking-slip',\n                param : \"shiphead_id:integer='\" + sel.data.shiphead_id + \"'\",\n                filename : 'picking-slip-' + sel.data.shiphead_number\n            },\n            success : function() {\n\n            }\n        })\n            \n            \n   \n}"
2152                },
2153                "text" : "Print Picking Slip",
2154                "xtype" : "Button",
2155                "cls" : "x-btn-text-icon",
2156                "$ icon" : "rootURL + '/Pman/templates/images/pdf.gif'",
2157                "$ xns" : "Roo.Toolbar"
2158               },
2159               {
2160                "listeners" : {
2161                 "click" : "function ()\n{\n    var sel  = _this.shipgrid.getSelectionModel().getSelected();\r\n    if (!sel) {\r\n        Roo.MessageBox.alert(\"Error\", \"Select a shipment\");\r\n        return;\r\n    }\r\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Xtuple/Print',\n            method : 'GET',\n            params : {\n                template : 'delivery-note-',\n                param : \"shiphead_id:integer='\" + sel.data.shiphead_id + \"'\",\n                filename : 'delivery-note-' + sel.data.shiphead_number\n            },\n            success : function() {\n\n            }\n        })\n            \n            \n   \n}"
2162                },
2163                "text" : "Print Delivery Note",
2164                "xtype" : "Button",
2165                "cls" : "x-btn-text-icon",
2166                "$ icon" : "rootURL + '/Pman/templates/images/pdf.gif'",
2167                "$ xns" : "Roo.Toolbar"
2168               },
2169               {
2170                "listeners" : {
2171                 "|click" : "function()\n{\n    var s = _this.shipgrid.getSelectionModel().getSelected();\n    \n    if(!s || s.data.shiphead_id * 1 < 1){\n        Roo.MessageBox.alert('Error', 'Please select a shipment');\n        return;\n    }\n    \n    new Pman.Request({\n        method: 'POST',\n        url: baseURL+ '/Roo/shiphead',\n        params : {\n            shiphead_id : s.data.shiphead_id,\n            _send_delivery : 1\n        },\n        success : function() {\n            Roo.MessageBox.alert('Notice', 'SENT');\n        }\n    });\n    \n}\n"
2172                },
2173                "text" : "Send Delivery Email",
2174                "xtype" : "Button",
2175                "cls" : "x-btn-text-icon",
2176                "$ icon" : "Roo.rootURL + 'images/default/dd/email.gif'",
2177                "$ xns" : "Roo.Toolbar"
2178               },
2179               {
2180                "xtype" : "Fill",
2181                "$ xns" : "Roo.Toolbar"
2182               },
2183               {
2184                "listeners" : {
2185                 "|click" : "function()\n{   \n    if (!_this.form.findField('cohead_id').getValue()) {\n        Roo.MessageBox.alert(\"Error\", \"Save Order first\");\n        return;\n    }\n    var rv = _this.form.getFieldValues();\n    \n    Pman.Dialog.XtupleShipmentNew.show({\n            shiphead_order_id : rv.cohead_id,\n            shiphead_shipdate :  _this.form.findField('cohead_targetdate').getValue().format('Y-m-d')\n        },\n        function() { \n             _this.shipgrid.ds.load({});\n        }\n    );\n}",
2186                 "render" : "function (_self)\n{\n  _this.addShipmentBtn = _self;\n}"
2187                },
2188                "text" : "Add",
2189                "xtype" : "Button",
2190                "cls" : "x-btn-text-icon",
2191                "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2192                "$ xns" : "Roo.Toolbar"
2193               },
2194               {
2195                "listeners" : {
2196                 "|click" : "function()\n{\n    var sel  = _this.shipgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a shipment\");\n        return;\n    }\n    // check current status of shipment..\n    \n    var msg = sel.data.shiphead_shipped ? \n        \"Are you sure you want to un-confirm that shipment? - It will remove items from unposted invoices\" : \n        \"Are you sure you want to void that shipment?\";\n    \n    Roo.MessageBox.confirm(\"Are you sure\", msg,\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                mask : 'Sending',\n                 timeout : 90000,\n                url : baseURL + '/Roo/shiphead',\n                method : 'POST',\n                \n                params : {\n                    shiphead_id : sel.data.shiphead_id,\n                    _void : 1\n                },\n                success : function() {\n                    _this.shipgrid.ds.load({});\n                }\n            })\n            \n        }\n    );\n            \n            \n    \n    \n    \n}\n        "
2197                },
2198                "text" : "Void / Unconfirm",
2199                "xtype" : "Button",
2200                "cls" : "x-btn-text-icon",
2201                "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
2202                "$ xns" : "Roo.Toolbar"
2203               }
2204              ]
2205             },
2206             {
2207              "xtype" : "ColumnModel",
2208              "header" : "number",
2209              "width" : 80,
2210              "$ renderer" : "function(v,x,r) {\n    if (r.json.shiphead_shipdate.length) {\n         return String.format('{0}', v); \n     }\n     return String.format('<s>{0}</s>', v); \n }",
2211              "$ xns" : "Roo.grid",
2212              "* prop" : "colModel[]",
2213              "dataIndex" : "shiphead_number",
2214              "# builderCfg" : "{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2215             },
2216             {
2217              "xtype" : "ColumnModel",
2218              "header" : "From Location",
2219              "width" : 100,
2220              "$ renderer" : "function(v) { return String.format('{0}', v); }",
2221              "$ xns" : "Roo.grid",
2222              "* prop" : "colModel[]",
2223              "dataIndex" : "shiphead_location_id_location_name"
2224             },
2225             {
2226              "xtype" : "ColumnModel",
2227              "header" : "Ship to",
2228              "width" : 100,
2229              "$ renderer" : "function(v) { return String.format('{0}', v); }",
2230              "$ xns" : "Roo.grid",
2231              "* prop" : "colModel[]",
2232              "dataIndex" : "shiphead_shipto_id_shipto_name"
2233             },
2234             {
2235              "xtype" : "ColumnModel",
2236              "header" : "shipdate",
2237              "width" : 75,
2238              "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
2239              "$ xns" : "Roo.grid",
2240              "* prop" : "colModel[]",
2241              "# builderCfg" : "{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2242              "dataIndex" : "shiphead_shipdate"
2243             },
2244             {
2245              "xtype" : "ColumnModel",
2246              "header" : "Status",
2247              "width" : 50,
2248              "$ renderer" : "function(v,x,r) { \n\n\n\n  \n    if (r.json.shiphead_shipdate.length) {\n    \n        if (r.json.shiphead_shipped) {\n            return \"Confirmed\";\n        }\n    \n         return '<span style=\"color:red\">Draft</span>';\n    }\n     \n    return 'VOID';\n   \n\n}",
2249              "$ xns" : "Roo.grid",
2250              "* prop" : "colModel[]",
2251              "dataIndex" : "shiphead_sfstatus",
2252              "# builderCfg" : "{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2253             },
2254             {
2255              "xtype" : "ColumnModel",
2256              "header" : "shipvia",
2257              "width" : 200,
2258              "$ renderer" : "function(v) { return String.format('{0}', v); }",
2259              "$ xns" : "Roo.grid",
2260              "* prop" : "colModel[]",
2261              "# builderCfg" : "{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}",
2262              "dataIndex" : "shiphead_shipvia"
2263             },
2264             {
2265              "xtype" : "ColumnModel",
2266              "header" : "tracknum",
2267              "width" : 200,
2268              "$ renderer" : "function(v) { return String.format('{0}', v); }",
2269              "$ xns" : "Roo.grid",
2270              "* prop" : "colModel[]",
2271              "# builderCfg" : "{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2272              "dataIndex" : "shiphead_tracknum"
2273             }
2274            ]
2275           }
2276          ]
2277         },
2278         {
2279          "listeners" : {
2280           "|activate" : "function() {\n    _this.invpanel = this;\n    if (_this.invgrid) {\n        _this.invgrid.ds.load({});\n    }\n}"
2281          },
2282          "background" : false,
2283          "region" : "center",
2284          "fitToframe" : true,
2285          "title" : "Invoices",
2286          "xtype" : "GridPanel",
2287          "fitContainer" : true,
2288          "$ xns" : "Roo",
2289          "tableName" : "cobmisc",
2290          "items" : [
2291           {
2292            "listeners" : {
2293             "|rowdblclick" : "function (_self, rowIndex, e)\n{\n\n    var ri = this.ds.getAt(rowIndex);\n    if ( ri.data.cobmisc_id < 0) { // skip summary row..\n        return;\n    }\n    var rv = _this.form.getFieldValues();\n   Pman.Dialog.XtupleInvoice.show({\n        cobmisc_id : ri.data.cobmisc_id,\n        // below parms for add credit memo\n        cmdata : {\n            cm_cust_id : rv.cohead_cust_id,\n            cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,\n            cm_curr_id : rv.cohead_curr_id,\n            cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,\n            cm_terms_id : rv.cohead_terms_id,\n            cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,\n            cm_salesrep_id : rv.cohead_salesrep_id,\n            cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,\n            cm_docdate : new Date(),\n            cm_taxzone_id : rv.cohead_taxzone_id,\n            cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,\n            cm_billto_cntct_id : rv.cohead_billto_cntct_id,\n            cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,\n            cm_location_src : rv.cohead_location_src,\n            cm_location_src_location_name : rv.cohead_location_src_location_name,\n            cm_billto_address : rv.billto_address\n        }\n    },\n        function() { \n         _this.invgrid.ds.load({});\n    });\n   \n}\n\n",
2294             "|render" : "function() \n{\n    _this.invgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.invpanel.active) {\n       this.ds.load({});\n    }\n}"
2295            },
2296            "autoExpandColumn" : "invchead_invcnumber",
2297            "xtype" : "Grid",
2298            "loadMask" : true,
2299            "$ xns" : "Roo.grid",
2300            "* prop" : "grid",
2301            "# builderCfg" : "{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_invcnumber\",\"columnshort\":\"invchead_invcnumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"invchead_invcnumber\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2302            "items" : [
2303             {
2304              "listeners" : {
2305               "beforeload" : "function (_self, options)\n{\n\n    options.params = options.params || {};\n    options.params.cobmisc_cohead_id = _this.form.findField('cohead_id').getValue() * 1;\n    if (options.params.cobmisc_cohead_id < 1) {\n        return false;\n    }\n    \n    options.params._with_other_payment = 1;\n    //options.params['query[invchead_ordernumber]']  = _this.form.findField('cohead_number').getValue()\n    \n}",
2306               "load" : "function (_self, records, options)\n{\n    var total = 0;\n    var done = 0;\n    var totalic = 0.0;\n    var totalfreight = 0.0;    \n    var totalmisc = 0.0;        \n    var totaltax = 0.0;        \n   \n    Roo.each(records, function(r)\n    {\n        if(r.data.cobmisc_id > 1){\n            done += parseInt(r.data.cobmisc_qty);\n            totalic += parseFloat(r.data.cobmisc_itemcost).toFixed(2)*1;        \n            totalmisc += parseFloat(r.data.cobmisc_misc).toFixed(2)*1;        \n            totalfreight += parseFloat(r.data.cobmisc_freight).toFixed(2)*1;                \n            totaltax += parseFloat(r.data.cobmisc_tax).toFixed(2)*1;                \n            total = parseInt(r.data.cobmisc_total_qty);\n        }\n       \n    });\n    \n    _this.shipinvtab.layout.getRegion('center').getPanel(0).setTitle(\n        (total == done) ?\n             \"Invoices (Complete)\" : \n            (\"Invoices prepared for \" +    done + '/' + total)\n    );\n\n    \n    var frtotal = (parseFloat(_this.form.findField('cohead_freight').getValue())  - totalfreight).toFixed(2);\n    var misctotal = (parseFloat(_this.form.findField('cohead_misc').getValue()) - totalmisc).toFixed(2);\n    var ictotal =  (parseFloat(_this.form.findField('cohead_subtotal').getValue()) - totalic).toFixed(2);\n    var taxtotal =  (parseFloat(_this.form.findField('cohead_tax').getValue())  - totaltax).toFixed(2);\n    var remtotal = frtotal*1 + misctotal*1 + ictotal*1 + taxtotal*1;\n    \n    var nr = this.reader.newRow({\n        cobmisc_id : -1,\n        cobmisc_invchead_id_invchead_invcnumber : \"Total Remaining\",\n        cobmisc_qty : total - done,\n        cobmisc_freight :frtotal,\n        cobmisc_misc : misctotal,        \n        cobmisc_itemcost  : ictotal,             \n        cobmisc_tax : taxtotal,\n        cobmisc_total : remtotal\n\n        \n    });\n    // do we need to add it somehow??\n    _this.invgrid.ds.add(nr);\n}"
2307              },
2308              "xtype" : "Store",
2309              "remoteSort" : true,
2310              "$ sortInfo" : "{ field : 'invchead_invcnumber', direction: 'ASC' }",
2311              "$ xns" : "Roo.data",
2312              "* prop" : "dataSource",
2313              "items" : [
2314               {
2315                "$ url" : "baseURL + '/Roo/cobmisc.php'",
2316                "xtype" : "HttpProxy",
2317                "method" : "GET",
2318                "$ xns" : "Roo.data",
2319                "* prop" : "proxy"
2320               },
2321               {
2322                "id" : "id",
2323                "root" : "data",
2324                "xtype" : "JsonReader",
2325                "$ fields" : "[\n    {\n        'name': 'invchead_invcnumber',\n        'type': 'string'\n    },\n    {\n        'name': 'invchead_invcdate',\n        'type': 'date'\n    }\n]",
2326                "$ xns" : "Roo.data",
2327                "* prop" : "reader",
2328                "# builderCfg" : "{\"cols\":[{\"table\":\"invchead\",\"column\":\"invchead_invcnumber\",\"columnshort\":\"invchead_invcnumber\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"},{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"invchead_invcnumber\"],\"table\":\"invchead\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2329                "totalProperty" : "total"
2330               }
2331              ]
2332             },
2333             {
2334              "xtype" : "Toolbar",
2335              "$ xns" : "Roo",
2336              "* prop" : "toolbar",
2337              "items" : [
2338               {
2339                "listeners" : {
2340                 "|click" : "function ()\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    // check current status of shipment..\n    \n    Roo.MessageBox.confirm(\"Are you sure\", \"Are you sure you want to Post that invoice?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n            new Pman.Request({\n               mask : 'Sending',\n                url : baseURL + '/Roo/cobmisc',\n                method : 'POST',\n                params : {\n                    cobmisc_id : sel.data.cobmisc_id,\n                    _post : 1\n                },\n                success : function() {\n                    _this.invgrid.ds.load({});\n                }\n            })\n            \n        }\n    );\n            \n            \n   \n}"
2341                },
2342                "text" : "Post Invoice",
2343                "xtype" : "Button",
2344                "cls" : "x-btn-text-icon",
2345                "$ icon" : "rootURL + '/Pman/templates/images/lock.gif'",
2346                "$ xns" : "Roo.Toolbar"
2347               },
2348               {
2349                "text" : "Print",
2350                "xtype" : "Button",
2351                "cls" : "x-btn-text-icon",
2352                "$ icon" : "rootURL + '/Pman/templates/images/pdf.gif'",
2353                "$ xns" : "Roo.Toolbar",
2354                "items" : [
2355                 {
2356                  "xtype" : "Menu",
2357                  "$ xns" : "Roo.menu",
2358                  "* prop" : "menu",
2359                  "items" : [
2360                   {
2361                    "listeners" : {
2362                     "click" : "function ()\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n                _print : 1\n            },\n            success : function() {\n\n            }\n        })\n            \n            \n   \n}"
2363                    },
2364                    "text" : "Print Standard Invoice",
2365                    "xtype" : "Item",
2366                    "$ xns" : "Roo.menu"
2367                   },
2368                   {
2369                    "listeners" : {
2370                     "click" : "function (_self, e)\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n                _print : 'cn'\n                \n            },\n            success : function() {\n\n            }\n        })\n            \n          \n} "
2371                    },
2372                    "$ hidden" : "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2373                    "text" : "Print Chinese Invoice With GST in line item",
2374                    "xtype" : "Item",
2375                    "$ xns" : "Roo.menu"
2376                   },
2377                   {
2378                    "listeners" : {
2379                     "click" : "function (_self, e)\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n                _print : 'cn-gst'\n                \n            },\n            success : function() {\n\n            }\n        })\n            \n          \n} "
2380                    },
2381                    "$ hidden" : "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2382                    "text" : "Print Chinese Invoice",
2383                    "xtype" : "Item",
2384                    "$ xns" : "Roo.menu"
2385                   },
2386                   {
2387                    "listeners" : {
2388                     "click" : "function (_self, e)\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n                _print : 'au-gst'\n                \n            },\n            success : function() {\n\n            }\n        })\n            \n          \n} "
2389                    },
2390                    "$ hidden" : "!(baseURL.match(/au\\.php$/))",
2391                    "text" : "Print Aus - GST included Invoice",
2392                    "xtype" : "Item",
2393                    "$ xns" : "Roo.menu"
2394                   },
2395                   {
2396                    "listeners" : {
2397                     "click" : "function (_self, e)\n{\n  var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n\n                _print : 'au-net',\n               ts: Math.random()\n            }\n        })\n\n\n}"
2398                    },
2399                    "$ hidden" : "!(baseURL.match(/au\\.php$/))",
2400                    "text" : "Print Bambini Pronto Invoice",
2401                    "xtype" : "Item",
2402                    "$ xns" : "Roo.menu"
2403                   },
2404                   {
2405                    "listeners" : {
2406                     "click" : "function (_self, e)\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if (!sel.data.cobmisc_invchead_id) {\n        Roo.MessageBox.alert(\"Error\", \"Invoice has not been posted\");\n        return;\n    }\n    // check current status of shipment..\n\n        new Pman.Download({\n            url : baseURL + '/Roo/invchead',\n            method : 'GET',\n            params : {\n                invchead_id : sel.data.cobmisc_invchead_id,\n                _print : 'au-proforma'\n                \n            },\n            success : function() {\n\n            }\n        })\n            \n          \n} "
2407                    },
2408                    "$ hidden" : "!(baseURL.match(/au\\.php$/))",
2409                    "text" : "Print Bambini Pro Forma Invoice",
2410                    "xtype" : "Item",
2411                    "$ xns" : "Roo.menu"
2412                   },
2413                   {
2414                    "listeners" : {
2415                     "click" : "function (_self, e)\n{\n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    \n    Pman.Dialog.XtupleDiscountOfInvoice.show({invchead_id : sel.data.cobmisc_invchead_id}, function(){\n\n    });\n}"
2416                    },
2417                    "$ hidden" : "!( baseURL.match(/au\\.php$/)) ",
2418                    "text" : "Print Shipping / Commercial Invoice",
2419                    "xtype" : "Item",
2420                    "$ xns" : "Roo.menu"
2421                   }
2422                  ]
2423                 }
2424                ]
2425               },
2426               {
2427                "text" : "Payments / Refunds / Credit Memos",
2428                "xtype" : "Button",
2429                "cls" : "x-btn-text-icon",
2430                "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
2431                "$ xns" : "Roo.Toolbar",
2432                "items" : [
2433                 {
2434                  "xtype" : "Menu",
2435                  "$ xns" : "Roo.menu",
2436                  "* prop" : "menu",
2437                  "items" : [
2438                   {
2439                    "listeners" : {
2440                     "click" : "function(_self,e)\n    {\n    \n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel || sel.data.cobmisc_id < 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    if(!sel.data.cobmisc_posted){\n        Roo.MessageBox.alert(\"Error\", \"This invoice has not been posted!\");\n        return;\n    }\n    if(sel.data.cobmisc_outstanding == 0){\n        Roo.MessageBox.alert(\"Error\", \"There is no any outstanding of this invoice!\");\n        return;\n    }\n    \n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if(!cust_id){\n        return;\n    }\n    var data = {\n        cashrcpt_amount : sel.data.cobmisc_outstanding,\n        cashrcpt_cust_id : cust_id,\n        cashrcpt_aropen_id : sel.data.cobmisc_aropen_id_aropen_id,\n        cashrcpt_distdate : new Date(),\n        cashrcpt_fundstype : 'C',\n        cashrcpt_curr_id : sel.data.cobmisc_curr_id_curr_id,\n        cashrcpt_curr_id_curr_name : sel.data.cobmisc_curr_id_curr_name,\n        cashrcpt_usecustdeposit : true,\n        cashrcpt_docdate : new Date(),\n        cashrcpt_salescat_id : -1,\n        cashrcpt_applydate : new Date(),\n        cashrcpt_discount : 0\n    };\n    Pman.Dialog.XtupleReceivePayment.show( data , function() {\n        _this.invgrid.ds.load({});\n    }); \n}\n"
2441                    },
2442                    "text" : "Receive Payment",
2443                    "xtype" : "Item",
2444                    "cls" : "x-btn-text-icon",
2445                    "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2446                    "$ xns" : "Roo.menu"
2447                   },
2448                   {
2449                    "listeners" : {
2450                     "click" : "function(_self,e)\n{\n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a credit memo\");\n        return;\n    }\n    if(!sel.data.cobmisc_posted){\n        Roo.MessageBox.alert(\"Error\", \"The invoice that credit memo has been applied to has been not posted\");\n        return;\n    }\n    var cust_id = _this.form.findField('cohead_cust_id').getValue();\n    if(!cust_id){\n        return;\n    }\n    \n    if(!sel.data.cobmisc_outstanding || sel.data.cobmisc_outstanding == 0){\n        Roo.MessageBox.alert(\"Error\", \"The amount of this credit memo is 0!\");\n        return;\n    }\n    \n    var d = _this.form.getFieldValues();\n    \n    var data = {\n        'checkhead_recip_id' : cust_id,\n        'checkhead_recip_type' : 'C',\n        'checkhead_checkdate' : new Date(),\n        'checkhead_amount' : sel.data.cobmisc_outstanding,\n        'remaining_total' : sel.data.cobmisc_outstanding,\n        'checkhead_curr_id' : d.cohead_curr_id,\n        'checkhead_curr_id_curr_name' : d.cohead_curr_id_curr_name,\n        'checkhead_misc' : true,\n        'aropen_id' : sel.data.cobmisc_cobapply_aropen_id,\n    \t'cmhead_number' : sel.data.cobmisc_invchead_id_invchead_invcnumber,\n\t'cust_name' : d.cohead_cust_id_cust_name,\n\t'_create_and_post' : 1\n\n    };\n    \n    \n    Pman.Dialog.XtupleMiscellaneousCheck.show( data , function() {\n        _this.invgrid.ds.load({});\n   }); \n}\n"
2451                    },
2452                    "text" : "Issue Refund",
2453                    "xtype" : "Item",
2454                    "cls" : "x-btn-text-icon",
2455                    "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2456                    "$ xns" : "Roo.menu"
2457                   },
2458                   {
2459                    "xtype" : "Separator",
2460                    "$ xns" : "Roo.menu"
2461                   },
2462                   {
2463                    "listeners" : {
2464                     "click" : "function(_self,e)\n{\n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel || sel.data.cobmisc_cashrcpt_id * 1 < 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a Receive Payment\");\n        return;\n    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Voiding receipt will mean you will have to re-enter the receipt refund - \" + \n                    \"please take note of the details so you can enter it again correctly later.\", function(r) {\n                            \n        if (r !='yes') {\n            return;\n        }\n        new Pman.Request({\n            url : baseURL + '/Roo/cashrcpt',\n            method : 'POST',\n            params : {\n                cashrcpt_id : sel.data.cobmisc_cashrcpt_id,\n                _void : 1\n            },\n            success : function() \n            {\n                _this.invgrid.ds.load({});\n            \n            }\n        });\n    \n   })\n    \n     \n}\n"
2465                    },
2466                    "text" : "Void Payment",
2467                    "xtype" : "Item",
2468                    "cls" : "x-btn-text-icon",
2469                    "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
2470                    "$ xns" : "Roo.menu"
2471                   },
2472                   {
2473                    "listeners" : {
2474                     "click" : "function(_self,e)\n{\n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel || sel.data.cobmisc_checkhead_id * 1 < 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a Miscellaneours Check\");\n        return;\n    }\n    \n    Roo.MessageBox.confirm(\"Confirm\", \"Voiding refund will mean you will have to re-enter the receipt refund - \" + \n                    \"please take note of the details so you can enter it again correctly later.\", function(r) {\n                            \n        if (r !='yes') {\n            return;\n        }\n        new Pman.Request({\n            url : baseURL + '/Roo/checkhead',\n            method : 'POST',\n            params : {\n                checkhead_id : sel.data.cobmisc_checkhead_id,\n                _voidPosted : 1\n            },\n            success : function() \n            {\n                _this.invgrid.ds.load({});\n            \n            }\n        });\n    \n   })\n    \n     \n}\n"
2475                    },
2476                    "text" : "Void Refund",
2477                    "xtype" : "Item",
2478                    "cls" : "x-btn-text-icon",
2479                    "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
2480                    "$ xns" : "Roo.menu"
2481                   },
2482                   {
2483                    "listeners" : {
2484                     "click" : "function(_self,e)\n{\n    var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel || sel.data.cobmisc_cobapply_aropen_id < 1) {\n        Roo.MessageBox.alert(\"Error\", \"Select a credit memo\");\n        return;\n    }\n    \n    if(sel.data.cobmisc_posted){\n        Roo.MessageBox.alert(\"Error\", \"You cann't void this credit memo, since the invoice that credit memo has been applied to has been posted\");\n        return;\n    }\n    \n    if (sel.data.cobmisc_cobapply_id < 1) {\n        Roo.MessageBox.alert(\"Error\", \"invaild credit memo\");\n        return;\n    }\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure want to void this applied credit memo, \" + \n                \"it will also void all the check that belongs to this credit memo \", function(r) {\n                            \n        if (r !='yes') {\n            return;\n        }\n        new Pman.Request({\n            url : baseURL + '/Roo/cobapply',\n            method : 'POST',\n            params : {\n                _delete : sel.data.cobmisc_cobapply_id,\n                _void : 1\n            },\n            success : function() \n            {\n                _this.invgrid.ds.load({});\n            \n            }\n        });\n    \n   })\n     \n}\n"
2485                    },
2486                    "text" : "Void Credit Memo",
2487                    "xtype" : "Item",
2488                    "cls" : "x-btn-text-icon",
2489                    "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
2490                    "$ xns" : "Roo.menu"
2491                   }
2492                  ]
2493                 }
2494                ]
2495               },
2496               {
2497                "xtype" : "Fill",
2498                "$ xns" : "Roo.Toolbar"
2499               },
2500               {
2501                "listeners" : {
2502                 "|click" : "function ()\n{\n\n    if (!_this.form.findField('cohead_id').getValue()) {\n        Roo.MessageBox.alert(\"Error\", \"Save Order first\");\n        return;\n    }\n    \n    var rv = _this.form.getFieldValues();\n    \n   \n   Pman.Dialog.XtupleInvoice.show({\n        cobmisc_cohead_id : rv.cohead_id,\n        cobmisc_shipdate :  _this.form.findField('cohead_targetdate').getValue(),\n        cobmisc_invcdate :  _this.form.findField('cohead_targetdate').getValue(),\n        cobmisc_curr_id : rv.cohead_curr_id,\n        cobmisc_curr_id_curr_name : rv.cohead_curr_id_curr_name,\n        // below parms for add credit memo\n        cmdata : {\n            cm_cust_id : rv.cohead_cust_id,\n            cm_cust_id_cust_name : rv.cohead_cust_id_cust_name,\n            cm_curr_id : rv.cohead_curr_id,\n            cm_curr_id_curr_name : rv.cohead_curr_id_curr_name,\n            cm_terms_id : rv.cohead_terms_id,\n            cm_terms_id_terms_descrip : rv.cohead_terms_id_terms_descrip,\n            cm_salesrep_id : rv.cohead_salesrep_id,\n            cm_salesrep_id_salesrep_name : rv.cohead_salesrep_id_salesrep_name,\n            cm_docdate : new Date(),\n            cm_taxzone_id : rv.cohead_taxzone_id,\n            cm_taxzone_id_taxzone_descrip : rv.cohead_taxzone_id_taxzone_descrip,\n            cm_billto_cntct_id : rv.cohead_billto_cntct_id,\n            cm_billto_cntct_id_cntct_name : rv.cohead_billto_cntct_id_cntct_name,\n            cm_location_src : rv.cohead_location_src,\n            cm_location_src_location_name : rv.cohead_location_src_location_name,\n            cm_billto_address : rv.billto_address\n        }\n        \n    },\n        function() { \n         _this.invgrid.ds.load({});\n    });\n   \n}",
2503                 "render" : "function (_self)\n{\n  _this.addInvoiceBtn = _self;\n}"
2504                },
2505                "text" : "Add",
2506                "xtype" : "Button",
2507                "cls" : "x-btn-text-icon",
2508                "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2509                "$ xns" : "Roo.Toolbar"
2510               },
2511               {
2512                "listeners" : {
2513                 "|click" : "function ()\n{\n\n     var sel  = _this.invgrid.getSelectionModel().getSelected();\n    if (!sel) {\n        Roo.MessageBox.alert(\"Error\", \"Select a invoice\");\n        return;\n    }\n    // check current status of shipment..\n    \n    var params =  {\n//        cobmisc_id : sel.data.cobmisc_id,\n        _void : 1\n    };\n    if (sel.data.cobmisc_id * 1) {\n        params.cobmisc_id = sel.data.cobmisc_id * 1 ;\n    }\n    if (sel.data.cobmisc_invchead_id_invchead_id * 1) {    \n        params.invchead_id  =  sel.data.cobmisc_invchead_id_invchead_id * 1;\n    }\n    \n    Roo.MessageBox.confirm(\"Are you sure\", \"Are you sure you want to VOID that invoice?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n            new Pman.Request({\n                mask : 'Sending',\n                url : baseURL + '/Roo/cobmisc',\n                method : 'POST',\n                params :  params,\n                success : function() {\n                    _this.invgrid.ds.load({});\n                }\n            })\n            \n        }\n    );\n            \n            \n   \n}"
2514                },
2515                "text" : "Void / Unpost",
2516                "xtype" : "Button",
2517                "cls" : "x-btn-text-icon",
2518                "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
2519                "$ xns" : "Roo.Toolbar"
2520               }
2521              ]
2522             },
2523             {
2524              "xtype" : "ColumnModel",
2525              "header" : "Invoice #",
2526              "width" : 100,
2527              "$ renderer" : "function(v,x,r) { \n       if (v && \n             r.data.cobmisc_invchead_id_invchead_id * 1 && \n            !r.data.cobmisc_invchead_id_invchead_posted) {\n           return  '<span style=\"color:red\">' + \n                \"NEEDS Voiding then re-posted: \" + \n                String.format('{0}', v) +\n                '</span>'; \n       }\n\n       if(v && r.data.cobmisc_id == -2){\n            return String.format('<span style=\"margin-left: 10px;\"> - {0} (Credit Memo)</span>', v); \n       }\n       if(v && r.data.cobmisc_id == -3){\n            return String.format('<span style=\"margin-left: 20px;\"> - {0} (Miscellaneous Check)</span>', v); \n       }\n      if(v && r.data.cobmisc_id == -4){\n            return String.format('<span style=\"margin-left: 10px;\"> - {0} (Receive Payment to {2}) [ {1} ]</span>', \n                    v, r.data.cobmisc_cashrcpt_amount, r.json.cashrcpt_bankaccnt_id_bankaccnt_bankname); \n       }\n       \n        return v ? String.format('{0}', v) : \n                '<span style=\"color:red\">' + \"Not Posted\" + '</span>'; \n}",
2528              "$ xns" : "Roo.grid",
2529              "* prop" : "colModel[]",
2530              "dataIndex" : "cobmisc_invchead_id_invchead_invcnumber"
2531             },
2532             {
2533              "xtype" : "ColumnModel",
2534              "header" : "invcdate",
2535              "width" : 75,
2536              "$ renderer" : "function(v,x,r) { \n    \n    return String.format('{0}', v && v.format ? v.format('d/M/Y') : ''); \n}",
2537              "$ xns" : "Roo.grid",
2538              "* prop" : "colModel[]",
2539              "dataIndex" : "cobmisc_invcdate",
2540              "# builderCfg" : "{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2541             },
2542             {
2543              "align" : "right",
2544              "xtype" : "ColumnModel",
2545              "header" : "Qty",
2546              "width" : 50,
2547              "$ renderer" : "function(v) { return String.format('{0}', v ? parseInt(v) : 0); }",
2548              "$ xns" : "Roo.grid",
2549              "* prop" : "colModel[]",
2550              "dataIndex" : "cobmisc_qty"
2551             },
2552             {
2553              "align" : "right",
2554              "xtype" : "ColumnModel",
2555              "header" : "Item Cost",
2556              "width" : 75,
2557              "$ renderer" : "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : 0); }",
2558              "$ xns" : "Roo.grid",
2559              "* prop" : "colModel[]",
2560              "dataIndex" : "cobmisc_itemcost"
2561             },
2562             {
2563              "align" : "right",
2564              "xtype" : "ColumnModel",
2565              "header" : "Shipping",
2566              "width" : 75,
2567              "$ renderer" : "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : ''); }",
2568              "$ xns" : "Roo.grid",
2569              "* prop" : "colModel[]",
2570              "dataIndex" : "cobmisc_freight"
2571             },
2572             {
2573              "align" : "right",
2574              "xtype" : "ColumnModel",
2575              "header" : "Tax",
2576              "width" : 75,
2577              "$ renderer" : "function(v,x,r) { \n\n    // tax is based on the % itemcost..\n//    var ic  = r.data.cobmisc_itemcost;\n    /*\n    var ic  =r.data.cobmisc_itemcost - (1* r.data.cobmisc_itemcost_taxfree);\n    \n    var tax= _this.form.findField('cohead_tax').getValue() * 1.0;\n    var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;    \n    if (tax < 0.1) {\n        return '';\n    }\n    var taxp = tax / totic;\n    var lv = taxp * ic;\n    */\n    return String.format('{0}', (1.0*v).toFixed(2) );\n    \n    \n }",
2578              "$ xns" : "Roo.grid",
2579              "* prop" : "colModel[]",
2580              "dataIndex" : "cobmisc_tax"
2581             },
2582             {
2583              "align" : "right",
2584              "xtype" : "ColumnModel",
2585              "header" : "Discount (Pretax)",
2586              "width" : 100,
2587              "$ renderer" : "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }",
2588              "$ xns" : "Roo.grid",
2589              "* prop" : "colModel[]",
2590              "dataIndex" : "cobmisc_cohead_id_cohead_pretax_discount"
2591             },
2592             {
2593              "align" : "right",
2594              "xtype" : "ColumnModel",
2595              "header" : "Discount (Posttax)",
2596              "width" : 100,
2597              "$ renderer" : "function(v,x,r) \n{\n    var vv = v - r.data.cobmisc_cohead_id_cohead_pretax_discount;\n    \n    return String.format('{0}', vv ? (1.0*vv).toFixed(2) : 0); \n}",
2598              "$ xns" : "Roo.grid",
2599              "* prop" : "colModel[]",
2600              "dataIndex" : "cobmisc_misc"
2601             },
2602             {
2603              "align" : "right",
2604              "xtype" : "ColumnModel",
2605              "header" : "Total ",
2606              "width" : 75,
2607              "$ renderer" : "function(v,x,r) { \n\n/*    \n    var ic  = r.data.cobmisc_itemcost;\n    var tax= _this.form.findField('cohead_tax').getValue() * 1.0;\n    var totic = _this.form.findField('cohead_subtotal').getValue() * 1.0;    \n    var     lv = 0.0;\n    if (tax > 0.0) {\n        var taxp = tax / totic;\n        lv = taxp * ic;\n\n    }\n  */  \n  \n\n    if(v){\n        return String.format('{0}',(v * 1.0).toFixed(2) );\n    }\n    var d= r.data;\n\n    return String.format('{0}',\n       ((d.cobmisc_itemcost * 1.0) + \n       (d.cobmisc_freight * 1.0) + \n       (d.cobmisc_tax * 1.0) +\n       (d.cobmisc_misc * 1.0)  \n\n       ).toFixed(2) );\n}",
2608              "$ xns" : "Roo.grid",
2609              "* prop" : "colModel[]",
2610              "dataIndex" : "cobmisc_total"
2611             },
2612             {
2613              "align" : "right",
2614              "xtype" : "ColumnModel",
2615              "header" : "Outstanding",
2616              "width" : 75,
2617              "$ renderer" : "function(v,x,r) \n{ \n    \n    return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );\n}",
2618              "$ xns" : "Roo.grid",
2619              "* prop" : "colModel[]",
2620              "dataIndex" : "cobmisc_outstanding"
2621             }
2622            ]
2623           }
2624          ]
2625         }
2626        ]
2627       }
2628      ]
2629     },
2630     {
2631      "listeners" : {
2632       "|activate" : "function() {\n    _this.hpanel = this;\n    if (_this.hgrid) {\n        _this.hgrid.footer.onClick('first');\n    }\n}"
2633      },
2634      "fitToframe" : true,
2635      "region" : "center",
2636      "background" : true,
2637      "title" : "History",
2638      "xtype" : "GridPanel",
2639      "fitContainer" : true,
2640      "$ xns" : "Roo",
2641      "# builderCfg" : "{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2642      "tableName" : "events",
2643      "items" : [
2644       {
2645        "listeners" : {
2646         "|rowdblclick" : "function (_self, rowIndex, e)\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",
2647         "|render" : "function() \n{\n    _this.hgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.hpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
2648        },
2649        "autoExpandColumn" : "remarks",
2650        "xtype" : "Grid",
2651        "loadMask" : true,
2652        "$ xns" : "Roo.grid",
2653        "* prop" : "grid",
2654        "# builderCfg" : "{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2655        "items" : [
2656         {
2657          "listeners" : {
2658           "beforeload" : "function (_self, options)\n{\n    options.params._related_on_table = 'cohead';\n    options.params._related_on_id = _this.form.findField('cohead_id').getValue();\n}"
2659          },
2660          "remoteSort" : true,
2661          "xtype" : "Store",
2662          "$ sortInfo" : "{ field : 'event_when', direction: 'DESC' }",
2663          "$ xns" : "Roo.data",
2664          "* prop" : "dataSource",
2665          "# builderCfg" : "{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2666          "items" : [
2667           {
2668            "$ url" : "baseURL + '/Roo/events.php'",
2669            "method" : "GET",
2670            "xtype" : "HttpProxy",
2671            "$ xns" : "Roo.data",
2672            "* prop" : "proxy"
2673           },
2674           {
2675            "id" : "id",
2676            "root" : "data",
2677            "xtype" : "JsonReader",
2678            "$ fields" : "[\n    {\n        'name': 'event_when',\n        'type': 'date'\n    },\n    {\n        'name': 'action',\n        'type': 'string'\n    },\n    {\n        'name': 'ipaddr',\n        'type': 'string'\n    },\n    {\n        'name': 'person_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    }\n]",
2679            "$ xns" : "Roo.data",
2680            "* prop" : "reader",
2681            "# builderCfg" : "{\"cols\":[{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}],\"cols_ex\":[\"remarks\"],\"table\":\"events\",\"xtype\":\"GridPanel\",\"|xns\":\"Roo\"}",
2682            "totalProperty" : "total"
2683           }
2684          ]
2685         },
2686         {
2687          "pageSize" : 25,
2688          "xtype" : "PagingToolbar",
2689          "emptyMsg" : "No events found",
2690          "$ xns" : "Roo",
2691          "displayInfo" : true,
2692          "displayMsg" : "Displaying events{0} - {1} of {2}",
2693          "* prop" : "footer"
2694         },
2695         {
2696          "xtype" : "ColumnModel",
2697          "header" : "Changed",
2698          "width" : 120,
2699          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }",
2700          "$ xns" : "Roo.grid",
2701          "* prop" : "colModel[]",
2702          "dataIndex" : "event_when",
2703          "# builderCfg" : "{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2704         },
2705         {
2706          "xtype" : "ColumnModel",
2707          "header" : "action",
2708          "width" : 120,
2709          "$ renderer" : "function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }",
2710          "$ xns" : "Roo.grid",
2711          "* prop" : "colModel[]",
2712          "dataIndex" : "action",
2713          "# builderCfg" : "{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2714         },
2715         {
2716          "xtype" : "ColumnModel",
2717          "header" : "IP address",
2718          "width" : 120,
2719          "$ renderer" : "function(v) { return String.format('{0}', v); }",
2720          "$ xns" : "Roo.grid",
2721          "* prop" : "colModel[]",
2722          "dataIndex" : "ipaddr",
2723          "# builderCfg" : "{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2724         },
2725         {
2726          "xtype" : "ColumnModel",
2727          "header" : "Who",
2728          "width" : 120,
2729          "$ renderer" : "function(v) { return String.format('{0}', v); }",
2730          "$ xns" : "Roo.grid",
2731          "* prop" : "colModel[]",
2732          "dataIndex" : "person_id_name",
2733          "# builderCfg" : "{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}"
2734         },
2735         {
2736          "xtype" : "ColumnModel",
2737          "header" : "Notes",
2738          "width" : 200,
2739          "$ renderer" : "function(v) { return String.format('{0}', v); }",
2740          "$ xns" : "Roo.grid",
2741          "* prop" : "colModel[]",
2742          "dataIndex" : "remarks",
2743          "# builderCfg" : "{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}"
2744         }
2745        ]
2746       }
2747      ]
2748     },
2749     {
2750      "region" : "center",
2751      "xtype" : "NestedLayoutPanel",
2752      "title" : "Stock Tx",
2753      "$ xns" : "Roo",
2754      "items" : [
2755       {
2756        "xtype" : "BorderLayout",
2757        "$ xns" : "Roo",
2758        "* prop" : "layout",
2759        "items" : [
2760         {
2761          "xtype" : "LayoutRegion",
2762          "$ xns" : "Roo",
2763          "* prop" : "center"
2764         },
2765         {
2766          "xtype" : "LayoutRegion",
2767          "width" : 500,
2768          "$ xns" : "Roo",
2769          "split" : true,
2770          "* prop" : "east"
2771         },
2772         {
2773          "listeners" : {
2774           "|activate" : "function() {\n    _this.txpanel = this;\n    if (_this.txgrid) {\n        _this.txgrid.footer.onClick('first');\n    }\n}"
2775          },
2776          "background" : false,
2777          "region" : "center",
2778          "fitToframe" : true,
2779          "title" : "invdetail",
2780          "xtype" : "GridPanel",
2781          "fitContainer" : true,
2782          "$ xns" : "Roo",
2783          "tableName" : "invdetail",
2784          "items" : [
2785           {
2786            "listeners" : {
2787             "|render" : "function() \n{\n    _this.txgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.txpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
2788            },
2789            "autoExpandColumn" : "item_number",
2790            "xtype" : "Grid",
2791            "loadMask" : true,
2792            "$ xns" : "Roo.grid",
2793            "* prop" : "grid",
2794            "items" : [
2795             {
2796              "xtype" : "Toolbar",
2797              "$ xns" : "Roo",
2798              "* prop" : "toolbar",
2799              "items" : [
2800               {
2801                "listeners" : {
2802                 "click" : "function (_self, e)\n{\n    new Pman.Request({\n        mask : 'applying',\n        url : baseURL + '/Roo/Cohead',\n        method : 'GET',\n        params : {\n            _apply_fifo : _this.form.findField('cohead_id').getValue()\n        },\n        success : function () {\n            Roo.MessageBox.alert(\"Applied\", \"Succesfully Applied\");\n        }\n    });\n}"
2803                },
2804                "text" : "Run Apply Fifo on order",
2805                "xtype" : "Button",
2806                "$ xns" : "Roo.Toolbar"
2807               },
2808               {
2809                "listeners" : {
2810                 "click" : "function (_self, e)\n{\n    new Pman.Request({\n        mask : 'running',\n        url : baseURL + '/Roo/Cohead',\n        method : 'GET',\n        params : {\n            _run_void_fix : _this.form.findField('cohead_id').getValue()\n        },\n        success : function () {\n            Roo.MessageBox.alert(\"Applied\", \"Succesfully Run\");\n        }\n    });\n}"
2811                },
2812                "text" : "Run Void flagger",
2813                "xtype" : "Button",
2814                "$ xns" : "Roo.Toolbar"
2815               },
2816               {
2817                "listeners" : {
2818                 "click" : "function (_self, e)\n{\n    new Pman.Download({\n        newWindow : true,\n        mask : 'running',\n        url : baseURL + '/Roo/Invdetail',\n        method : 'GET',\n        timeout :90000,\n        params : {\n            _post : 1,\n            _reverse_all_bad : _this.form.findField('cohead_id').getValue()\n        },\n        success : function () {\n            Roo.MessageBox.alert(\"Applied\", \"Succesfully Run\");\n        }\n    });\n}"
2819                },
2820                "text" : "Auto Reverse",
2821                "xtype" : "Button",
2822                "$ xns" : "Roo.Toolbar"
2823               }
2824              ]
2825             },
2826             {
2827              "listeners" : {
2828               "selectionchange" : "function (_self)\n{\n    _this.txdgrid.footer.onClick('first');;\n}"
2829              },
2830              "xtype" : "RowSelectionModel",
2831              "singleSelect" : true,
2832              "$ xns" : "Roo.grid",
2833              "* prop" : "sm"
2834             },
2835             {
2836              "listeners" : {
2837               "beforeload" : "function (_self, o)\n{\n    o.params.cohead_id = _this.form.findField('cohead_id').getValue();\n    if (! o.params.cohead_id ) {\n        this.removeAll();\n        return false;\n    }\n}"
2838              },
2839              "xtype" : "Store",
2840              "remoteSort" : true,
2841              "$ sortInfo" : "{ field : 'item_number', direction: 'ASC' }",
2842              "$ xns" : "Roo.data",
2843              "* prop" : "dataSource",
2844              "items" : [
2845               {
2846                "$ url" : "baseURL + '/Roo/invdetail.php'",
2847                "xtype" : "HttpProxy",
2848                "method" : "GET",
2849                "$ xns" : "Roo.data",
2850                "* prop" : "proxy"
2851               },
2852               {
2853                "id" : "id",
2854                "root" : "data",
2855                "xtype" : "JsonReader",
2856                "$ xns" : "Roo.data",
2857                "$ fields" : "[\n    {\n        'name': 'invdetail_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_transtype',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_invhist_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_location_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_qty',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_comments',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_qty_before',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_qty_after',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_invcitem_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_expiration',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_warrpurc',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_ls_id',\n        'type': 'int'\n    }\n]",
2858                "* prop" : "reader",
2859                "totalProperty" : "total"
2860               }
2861              ]
2862             },
2863             {
2864              "pageSize" : 9999,
2865              "xtype" : "PagingToolbar",
2866              "emptyMsg" : "No invdetail found",
2867              "$ xns" : "Roo",
2868              "displayMsg" : "Displaying invdetail{0} - {1} of {2}",
2869              "displayInfo" : true,
2870              "* prop" : "footer"
2871             },
2872             {
2873              "xtype" : "ColumnModel",
2874              "header" : "Item",
2875              "width" : 75,
2876              "$ renderer" : "function(v) { return String.format('{0}', v); }",
2877              "$ xns" : "Roo.grid",
2878              "* prop" : "colModel[]",
2879              "dataIndex" : "item_number"
2880             },
2881             {
2882              "align" : "right",
2883              "xtype" : "ColumnModel",
2884              "header" : "#Ship",
2885              "width" : 50,
2886              "$ renderer" : "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2887              "$ xns" : "Roo.grid",
2888              "* prop" : "colModel[]",
2889              "dataIndex" : "rec_shipped"
2890             },
2891             {
2892              "align" : "right",
2893              "xtype" : "ColumnModel",
2894              "header" : "#Ret",
2895              "width" : 50,
2896              "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2897              "$ xns" : "Roo.grid",
2898              "* prop" : "colModel[]",
2899              "dataIndex" : "rec_returned"
2900             },
2901             {
2902              "align" : "right",
2903              "xtype" : "ColumnModel",
2904              "header" : "#TX ship",
2905              "width" : 50,
2906              "$ renderer" : "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2907              "$ xns" : "Roo.grid",
2908              "* prop" : "colModel[]",
2909              "dataIndex" : "tx_shipped"
2910             },
2911             {
2912              "align" : "right",
2913              "xtype" : "ColumnModel",
2914              "header" : "#TX ret",
2915              "width" : 50,
2916              "$ renderer" : "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2917              "$ xns" : "Roo.grid",
2918              "* prop" : "colModel[]",
2919              "dataIndex" : "tx_returned"
2920             },
2921             {
2922              "align" : "right",
2923              "xtype" : "ColumnModel",
2924              "header" : "#TX Tot",
2925              "width" : 50,
2926              "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2927              "$ xns" : "Roo.grid",
2928              "* prop" : "colModel[]",
2929              "dataIndex" : "tx_total"
2930             },
2931             {
2932              "align" : "right",
2933              "xtype" : "ColumnModel",
2934              "header" : "Value",
2935              "width" : 50,
2936              "$ renderer" : "function(v,x,r) { \n\n    return (v*1).toFixed(3);\n}",
2937              "$ xns" : "Roo.grid",
2938              "* prop" : "colModel[]",
2939              "dataIndex" : "total_value"
2940             },
2941             {
2942              "align" : "right",
2943              "xtype" : "ColumnModel",
2944              "header" : "#Diff",
2945              "width" : 50,
2946              "$ renderer" : "function(v,x,r) { \n\n    var cototal = (r.data.rec_returned*1) - (r.data.rec_shipped*1);\n//    Roo.log(cototal);\n    var diff = (v*1) - cototal;\n //   Roo.log(diff);\n    if (diff == 0)  {\n        return '';\n    }\n    return String.format('<span style=\"color:red\">{0}</span>',  diff ); \n    }",
2947              "$ xns" : "Roo.grid",
2948              "* prop" : "colModel[]",
2949              "dataIndex" : "tx_total"
2950             }
2951            ]
2952           }
2953          ]
2954         },
2955         {
2956          "listeners" : {
2957           "|activate" : "function() {\n    _this.txdpanel = this;\n    if (_this.txdgrid) {\n        _this.txdgrid.footer.onClick('first');\n    }\n}"
2958          },
2959          "background" : false,
2960          "region" : "east",
2961          "fitToframe" : true,
2962          "title" : "invdetail",
2963          "xtype" : "GridPanel",
2964          "fitContainer" : true,
2965          "$ xns" : "Roo",
2966          "tableName" : "invdetail",
2967          "items" : [
2968           {
2969            "listeners" : {
2970             "|render" : "function() \n{\n    _this.txdgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.txdpanel.active) {\n       this.footer.onClick('first');\n    }\n}",
2971             "rowclick" : "function (_self, rowIndex, e)\n{\n    var s = _this.txdgrid.ds.getAt(rowIndex);\n    var dt = s.data.invhist_transdate.split(' ');\n    \n    _this.dateSel.setValue(new Date(dt[0]));\n}"
2972            },
2973            "autoExpandColumn" : "invhist_comments",
2974            "xtype" : "Grid",
2975            "loadMask" : true,
2976            "$ xns" : "Roo.grid",
2977            "* prop" : "grid",
2978            "items" : [
2979             {
2980              "xtype" : "Toolbar",
2981              "$ xns" : "Roo",
2982              "* prop" : "toolbar",
2983              "items" : [
2984               {
2985                "listeners" : {
2986                 "click" : "function (_self, e)\n{\n    var s = _this.txdgrid.selModel.getSelected();\n\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a transaction\");\n        return;\n    }\n    \n    var reverseSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/invdetail',\n            method : 'POST',\n            params : {\n                _duplicate : s.data.invdetail_id\n            }, \n            success : function() {\n                _this.txdgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    \n    \n\n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n        function(x) {\n            if (x != 'yes') {\n                return;\n            }\n            reverseSel();\n        }\n    );\n                        \n    \n    \n    \n}"
2987                },
2988                "text" : "Duplicate Selected",
2989                "xtype" : "Button",
2990                "$ xns" : "Roo.Toolbar"
2991               },
2992               {
2993                "xtype" : "Fill",
2994                "$ xns" : "Roo.Toolbar"
2995               },
2996               {
2997                "text" : "Issue Date",
2998                "xtype" : "TextItem",
2999                "$ xns" : "Roo.Toolbar"
3000               },
3001               {
3002                "listeners" : {
3003                 "render" : "function (_self)\n{\n    _this.dateSel = _self;\n}"
3004                },
3005                "format" : "Y-m-d",
3006                "fieldLabel" : "Issue Date",
3007                "xtype" : "DateField",
3008                "allowBlank" : false,
3009                "width" : 150,
3010                "$ xns" : "Roo.form",
3011                "name" : "issue_date"
3012               },
3013               {
3014                "listeners" : {
3015                 "click" : "function (_self, e)\n{\n    var s = _this.txdgrid.selModel.getSelected();\n    var dt = _this.dateSel.getValue();\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select a transaction\");\n        return;\n    }\n    \n    var reverseSel = function(force) {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/invdetail',\n            method : 'POST',\n            params : {\n                _reverse : s.data.invdetail_id,\n                _as_of : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),\n                _force : force\n            }, \n            success : function() {\n                _this.txdgrid.footer.onClick('first');\n            },\n            failure : function(res) {\n                Roo.log(res);\n                try {\n                    if (res.errors.confirm) {\n                                      \n                        Roo.MessageBox.confirm(\n                            \"Confirm\", \n                            \"are you really sure the totals will get messed up.\",\n                            function(x) {\n                                if (x != 'yes') {\n                                    return;\n                                }\n                                reverseSel(1);\n                            }\n                        );\n                        return;\n                    }\n                } catch(e) { }\n                Roo.MessageBox.alert(\"Error\", res.errorMsg);\n                \n                \n            }\n        });\n    \n    }\n    \n    \n\n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n        function(x) {\n            if (x != 'yes') {\n                return;\n            }\n            reverseSel(0);\n        }\n    );\n                        \n    \n    \n    \n}"
3016                },
3017                "text" : "Reverse Selected",
3018                "xtype" : "Button",
3019                "$ xns" : "Roo.Toolbar"
3020               }
3021              ]
3022             },
3023             {
3024              "listeners" : {
3025               "beforeload" : "function (_self, o)\n{\n    o.params.cohead_id = _this.form.findField('cohead_id').getValue();\n    var s = _this.txgrid.selModel.getSelected();\n    if (!s) { \n        this.removeAll();\n        return false;\n    }\n    o.params.itemsite_id = s.data.invhist_itemsite_id;\n    \n}"
3026              },
3027              "xtype" : "Store",
3028              "remoteSort" : true,
3029              "$ sortInfo" : "{ field : 'invdetail_id', direction: 'ASC' }",
3030              "$ xns" : "Roo.data",
3031              "* prop" : "dataSource",
3032              "items" : [
3033               {
3034                "$ url" : "baseURL + '/Roo/invdetail.php'",
3035                "xtype" : "HttpProxy",
3036                "method" : "GET",
3037                "$ xns" : "Roo.data",
3038                "* prop" : "proxy"
3039               },
3040               {
3041                "id" : "id",
3042                "root" : "data",
3043                "xtype" : "JsonReader",
3044                "$ xns" : "Roo.data",
3045                "$ fields" : "[\n    {\n        'name': 'invdetail_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_transtype',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_invhist_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_location_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_qty',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_comments',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_qty_before',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_qty_after',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_invcitem_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_expiration',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_warrpurc',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_ls_id',\n        'type': 'int'\n    }\n]",
3046                "* prop" : "reader",
3047                "totalProperty" : "total"
3048               }
3049              ]
3050             },
3051             {
3052              "pageSize" : 9999,
3053              "xtype" : "PagingToolbar",
3054              "emptyMsg" : "No invdetail found",
3055              "$ xns" : "Roo",
3056              "displayMsg" : "Displaying invdetail{0} - {1} of {2}",
3057              "displayInfo" : true,
3058              "* prop" : "footer"
3059             },
3060             {
3061              "xtype" : "ColumnModel",
3062              "header" : "TX#",
3063              "width" : 60,
3064              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3065              "$ xns" : "Roo.grid",
3066              "* prop" : "colModel[]",
3067              "dataIndex" : "invdetail_id"
3068             },
3069             {
3070              "xtype" : "ColumnModel",
3071              "header" : "Date",
3072              "width" : 75,
3073              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3074              "$ xns" : "Roo.grid",
3075              "* prop" : "colModel[]",
3076              "dataIndex" : "invhist_transdate"
3077             },
3078             {
3079              "xtype" : "ColumnModel",
3080              "header" : "Ref#",
3081              "width" : 75,
3082              "$ renderer" : "function(v,x,r) {\n    if (r.data.invfifo_void *1 != 0) {\n        return String.format('<s>{0}</s>', v); \n    }\n\n     return String.format('{0}', v); \n }",
3083              "$ xns" : "Roo.grid",
3084              "* prop" : "colModel[]",
3085              "dataIndex" : "invhist_ordnumber"
3086             },
3087             {
3088              "xtype" : "ColumnModel",
3089              "header" : "TX#",
3090              "width" : 60,
3091              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3092              "$ xns" : "Roo.grid",
3093              "* prop" : "colModel[]",
3094              "dataIndex" : "location_name"
3095             },
3096             {
3097              "xtype" : "ColumnModel",
3098              "header" : "Notes",
3099              "width" : 75,
3100              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3101              "$ xns" : "Roo.grid",
3102              "* prop" : "colModel[]",
3103              "dataIndex" : "invhist_comments"
3104             },
3105             {
3106              "align" : "right",
3107              "xtype" : "ColumnModel",
3108              "header" : "Qty Changed",
3109              "width" : 50,
3110              "$ renderer" : "function(v,x,r) {\n    if ( r.data.coitem_shipped != v) {\n        return String.format('{0} <span style=\"color:red\">({1})</span>',\n             Roo.util.Format.number(v,0),\n             r.data.coitem_shipped\n         );\n    \n    }\n     return String.format('{0}', Roo.util.Format.number(v,0));\n}",
3111              "$ xns" : "Roo.grid",
3112              "* prop" : "colModel[]",
3113              "dataIndex" : "invdetail_qty"
3114             },
3115             {
3116              "align" : "right",
3117              "xtype" : "ColumnModel",
3118              "header" : "Qty Changed",
3119              "width" : 75,
3120              "$ renderer" : "function(v,x,r) {\n    var tot = r.data.invhist_value_after*1 - v*1;\n    var f = '{0}';\n    if (r.data.invdetail_qty >0 && tot < 0) {\n        f = '<span style=\"color:red\">{0}</span>';\n    }\n    if (r.data.invdetail_qty < 0 && tot > 0) {\n        f = '<span style=\"color:red\">{0}</span>';\n    }    \n    return String.format(f, Roo.util.Format.number(tot));\n}",
3121              "$ xns" : "Roo.grid",
3122              "* prop" : "colModel[]",
3123              "dataIndex" : "invhist_value_before"
3124             },
3125             {
3126              "xtype" : "ColumnModel",
3127              "header" : "Posted",
3128              "width" : 40,
3129              "$ renderer" : "function(v,x,r) { \n    \n    var state = v   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
3130              "$ xns" : "Roo.grid",
3131              "* prop" : "colModel[]",
3132              "dataIndex" : "invhist_posted"
3133             }
3134            ]
3135           }
3136          ]
3137         }
3138        ]
3139       }
3140      ]
3141     },
3142     {
3143      "region" : "center",
3144      "xtype" : "NestedLayoutPanel",
3145      "title" : "GL Tx",
3146      "$ xns" : "Roo",
3147      "items" : [
3148       {
3149        "xtype" : "BorderLayout",
3150        "$ xns" : "Roo",
3151        "* prop" : "layout",
3152        "items" : [
3153         {
3154          "xtype" : "LayoutRegion",
3155          "$ xns" : "Roo",
3156          "* prop" : "center"
3157         },
3158         {
3159          "xtype" : "LayoutRegion",
3160          "width" : 500,
3161          "$ xns" : "Roo",
3162          "split" : true,
3163          "* prop" : "east"
3164         },
3165         {
3166          "listeners" : {
3167           "|activate" : "function() {\n    _this.gltxpanel = this;\n    if (_this.gltxgrid) {\n        _this.gltxgrid.footer.onClick('first');\n    }\n}"
3168          },
3169          "background" : false,
3170          "region" : "center",
3171          "fitToframe" : true,
3172          "title" : "invdetail",
3173          "xtype" : "GridPanel",
3174          "fitContainer" : true,
3175          "$ xns" : "Roo",
3176          "tableName" : "invdetail",
3177          "items" : [
3178           {
3179            "listeners" : {
3180             "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    if (columnIndex > 0) {\n        return;\n    }\n    var rec = this.ds.getAt(rowIndex);\n    rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);\n    _this.gltxdgrid.footer.onClick('first');\n}",
3181             "|render" : "function() \n{\n    _this.gltxgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
3182            },
3183            "autoExpandColumn" : "gltrans_accnt_id_accnt_descrip",
3184            "xtype" : "Grid",
3185            "loadMask" : true,
3186            "$ xns" : "Roo.grid",
3187            "* prop" : "grid",
3188            "items" : [
3189             {
3190              "listeners" : {
3191               "selectionchange" : "function (_self)\n{\n    _this.gltxdgrid.footer.onClick('first');;\n}"
3192              },
3193              "xtype" : "RowSelectionModel",
3194              "singleSelect" : true,
3195              "$ xns" : "Roo.grid",
3196              "* prop" : "sm"
3197             },
3198             {
3199              "listeners" : {
3200               "beforeload" : "function (_self, o)\n{\n    o.params.cohead_id = _this.form.findField('cohead_id').getValue();\n    if (! o.params.cohead_id ) {\n        this.removeAll();\n        return false;\n    }\n    o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;\n}"
3201              },
3202              "xtype" : "Store",
3203              "remoteSort" : true,
3204              "$ sortInfo" : "{ field : 'item_number', direction: 'ASC' }",
3205              "$ xns" : "Roo.data",
3206              "* prop" : "dataSource",
3207              "items" : [
3208               {
3209                "$ url" : "baseURL + '/Roo/gltrans.php'",
3210                "xtype" : "HttpProxy",
3211                "method" : "GET",
3212                "$ xns" : "Roo.data",
3213                "* prop" : "proxy"
3214               },
3215               {
3216                "id" : "id",
3217                "root" : "data",
3218                "xtype" : "JsonReader",
3219                "$ xns" : "Roo.data",
3220                "$ fields" : "[\n    {\n        'name': 'invdetail_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_transtype',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_invhist_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_location_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_qty',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_comments',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_qty_before',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_qty_after',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_invcitem_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_expiration',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_warrpurc',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_ls_id',\n        'type': 'int'\n    }\n]",
3221                "* prop" : "reader",
3222                "totalProperty" : "total"
3223               }
3224              ]
3225             },
3226             {
3227              "pageSize" : 9999,
3228              "xtype" : "PagingToolbar",
3229              "emptyMsg" : "No invdetail found",
3230              "$ xns" : "Roo",
3231              "displayMsg" : "Displaying invdetail{0} - {1} of {2}",
3232              "displayInfo" : true,
3233              "* prop" : "footer",
3234              "items" : [
3235               {
3236                "listeners" : {
3237                 "render" : "function (_self)\n{\n    _this.glsalesbtn = _self;\n}",
3238                 "click" : "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
3239                },
3240                "text" : "Split sales",
3241                "enableToggle" : true,
3242                "pressed" : true,
3243                "xtype" : "Button",
3244                "$ xns" : "Roo.Toolbar"
3245               }
3246              ]
3247             },
3248             {
3249              "xtype" : "ColumnModel",
3250              "header" : "Summary",
3251              "width" : 50,
3252              "$ renderer" : "function(v,x,r) { \n    \n    var state = v*1   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
3253              "$ xns" : "Roo.grid",
3254              "* prop" : "colModel[]",
3255              "dataIndex" : "gltrans_as_summary"
3256             },
3257             {
3258              "xtype" : "ColumnModel",
3259              "header" : "Account",
3260              "width" : 75,
3261              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3262              "$ xns" : "Roo.grid",
3263              "* prop" : "colModel[]",
3264              "dataIndex" : "gltrans_accnt_id_accnt_descrip"
3265             },
3266             {
3267              "align" : "right",
3268              "xtype" : "ColumnModel",
3269              "header" : "Credit",
3270              "width" : 75,
3271              "$ renderer" : "function(v) { return String.format('{0}',  Roo.util.Format.number(v,3)); }",
3272              "$ xns" : "Roo.grid",
3273              "* prop" : "colModel[]",
3274              "dataIndex" : "gltrans_amount_credit"
3275             },
3276             {
3277              "align" : "right",
3278              "xtype" : "ColumnModel",
3279              "header" : "Debit",
3280              "width" : 75,
3281              "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3282              "$ xns" : "Roo.grid",
3283              "* prop" : "colModel[]",
3284              "dataIndex" : "gltrans_amount_debit"
3285             },
3286             {
3287              "align" : "right",
3288              "xtype" : "ColumnModel",
3289              "header" : "Sum",
3290              "width" : 75,
3291              "$ renderer" : "function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }",
3292              "$ xns" : "Roo.grid",
3293              "* prop" : "colModel[]",
3294              "dataIndex" : "gltrans_amount_total"
3295             },
3296             {
3297              "align" : "right",
3298              "xtype" : "ColumnModel",
3299              "header" : "Unposted",
3300              "width" : 75,
3301              "$ renderer" : "function(v) { return String.format('<span style=\"color:red\">{0}</span>', Roo.util.Format.number(v,3)); }",
3302              "$ xns" : "Roo.grid",
3303              "* prop" : "colModel[]",
3304              "dataIndex" : "gltrans_amount_total_unposted"
3305             }
3306            ]
3307           }
3308          ]
3309         },
3310         {
3311          "listeners" : {
3312           "|activate" : "function() {\n    _this.gltxdpanel = this;\n    if (_this.gltxdgrid) {\n        _this.gltxdgrid.footer.onClick('first');\n    }\n}"
3313          },
3314          "background" : false,
3315          "region" : "east",
3316          "fitToframe" : true,
3317          "title" : "invdetail",
3318          "xtype" : "GridPanel",
3319          "fitContainer" : true,
3320          "$ xns" : "Roo",
3321          "tableName" : "invdetail",
3322          "items" : [
3323           {
3324            "listeners" : {
3325             "cellclick" : "function (_self, ri, ci, e)\n{\n    \n      var deleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _void : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', false);\n                rec.set('gltrans_deleted', true);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    var undeleteSel = function() {\n    \n        new Pman.Request({\n            mask : \"Reversing\",\n            url : baseURL + '/Roo/gltrans',\n            method : 'POST',\n            params : {  \n                _unvoid : 1,\n                gltrans_id : rec.data.gltrans_id\n                \n            }, \n            success : function() {\n                rec.set('gltrans_posted', true);\n                rec.set('gltrans_deleted', false);\n                rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);\n               _this.gltxgrid.footer.onClick('first');\n            }\n        });\n    \n    }\n    \n    var di = this.colModel.config[ci].dataIndex;\n    if (di != 'gltrans_posted') {\n        return;\n    }\n    \n    \n    \n    var rec = this.ds.getAt(ri);\n    if (rec.data.gltrans_deleted) {\n    \n         Roo.MessageBox.confirm(\n            \"Confirm\", \n            \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n            function(x) {\n                if (x != 'yes') {\n                    return;\n                }\n                undeleteSel();\n            }\n        );\n    \n        return false;\n    }\n\n    \n    \n    if (!rec.data.gltrans_posted) {\n\n        \n        \n        new Pman.Request({\n            method : 'POST',\n            url : baseURL + '/Roo/gltrans',\n            mask : \"Posting\",\n            params : {\n                _post : 1,\n                gltrans_id : rec.data.gltrans_id\n            },\n            success : function (res)\n            {\n                rec.set('gltrans_posted', true);\n                _this.gltxgrid.footer.onClick('first');\n            \n            }\n        \n        \n        });\n        return;\n    }\n    \n    // we have a posted transaction.\n    // only allow recalled to be deleted..\n    if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {\n        return false;\n    }\n    \n    \n \n    \n    \n\n    Roo.MessageBox.confirm(\n        \"Confirm\", \n        \"This should only be used by System Administrators - are you sure you know what you are doing!\",\n        function(x) {\n            if (x != 'yes') {\n                return;\n            }\n            deleteSel();\n        }\n    );\n          \n    \n    \n}",
3326             "|render" : "function() \n{\n    _this.gltxdgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.gltxdpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
3327            },
3328            "autoExpandColumn" : "gltrans_notes",
3329            "xtype" : "Grid",
3330            "loadMask" : true,
3331            "$ xns" : "Roo.grid",
3332            "* prop" : "grid",
3333            "items" : [
3334             {
3335              "listeners" : {
3336               "beforeload" : "function (_self, o)\n{\n    o.params.cohead_id = _this.form.findField('cohead_id').getValue();\n    var s = _this.gltxgrid.selModel.getSelected();\n    if (!s) { \n        this.removeAll();\n        return false;\n    }\n    o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;\n    o.params.gltrans_is_ship = s.data.gltrans_is_ship;\n    o.params.gltrans_as_summary =     s.data.gltrans_as_summary;\n    \n    \n}"
3337              },
3338              "xtype" : "Store",
3339              "remoteSort" : true,
3340              "$ sortInfo" : "{ field : 'gltrans_docnumber', direction: 'ASC' }",
3341              "$ xns" : "Roo.data",
3342              "* prop" : "dataSource",
3343              "items" : [
3344               {
3345                "$ url" : "baseURL + '/Roo/gltrans.php'",
3346                "xtype" : "HttpProxy",
3347                "method" : "GET",
3348                "$ xns" : "Roo.data",
3349                "* prop" : "proxy"
3350               },
3351               {
3352                "id" : "id",
3353                "root" : "data",
3354                "xtype" : "JsonReader",
3355                "$ xns" : "Roo.data",
3356                "$ fields" : "[\n    {\n        'name': 'invdetail_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_transtype',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_invhist_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_location_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_qty',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_comments',\n        'type': 'string'\n    },\n    {\n        'name': 'invdetail_qty_before',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_qty_after',\n        'type': 'float'\n    },\n    {\n        'name': 'invdetail_invcitem_id',\n        'type': 'int'\n    },\n    {\n        'name': 'invdetail_expiration',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_warrpurc',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'invdetail_ls_id',\n        'type': 'int'\n    }\n]",
3357                "* prop" : "reader",
3358                "totalProperty" : "total"
3359               }
3360              ]
3361             },
3362             {
3363              "pageSize" : 9999,
3364              "xtype" : "PagingToolbar",
3365              "emptyMsg" : "No invdetail found",
3366              "$ xns" : "Roo",
3367              "displayMsg" : "Displaying invdetail{0} - {1} of {2}",
3368              "displayInfo" : true,
3369              "* prop" : "footer",
3370              "items" : [
3371               {
3372                "listeners" : {
3373                 "click" : "function (_self, e)\n{\n    new Pman.Download( {\n        grid : _this.gltxdgrid\n    \n    });\n}"
3374                },
3375                "text" : "Download",
3376                "xtype" : "Button",
3377                "$ xns" : "Roo.Toolbar"
3378               }
3379              ]
3380             },
3381             {
3382              "xtype" : "ColumnModel",
3383              "sortable" : true,
3384              "header" : "Ref#",
3385              "width" : 75,
3386              "$ renderer" : "function(v) { return String.format('{0}', v ); }",
3387              "$ xns" : "Roo.grid",
3388              "* prop" : "colModel[]",
3389              "dataIndex" : "gltrans_id"
3390             },
3391             {
3392              "xtype" : "ColumnModel",
3393              "header" : "Date",
3394              "width" : 75,
3395              "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
3396              "$ xns" : "Roo.grid",
3397              "* prop" : "colModel[]",
3398              "dataIndex" : "gltrans_date"
3399             },
3400             {
3401              "xtype" : "ColumnModel",
3402              "header" : "Doc#",
3403              "width" : 75,
3404              "$ renderer" : "function(v,x,r) { \n    if (r.data.gltrans_deleted) {\n       return String.format('<s>{0}</s>', v);     \n    }\n    return String.format('{0}', v); \n}",
3405              "$ xns" : "Roo.grid",
3406              "* prop" : "colModel[]",
3407              "dataIndex" : "gltrans_docnumber"
3408             },
3409             {
3410              "xtype" : "ColumnModel",
3411              "header" : "Source",
3412              "width" : 50,
3413              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3414              "$ xns" : "Roo.grid",
3415              "* prop" : "colModel[]",
3416              "dataIndex" : "gltrans_source"
3417             },
3418             {
3419              "xtype" : "ColumnModel",
3420              "header" : "Notes",
3421              "width" : 75,
3422              "$ renderer" : "function(v) { return String.format('{0}', v); }",
3423              "$ xns" : "Roo.grid",
3424              "* prop" : "colModel[]",
3425              "dataIndex" : "gltrans_notes"
3426             },
3427             {
3428              "align" : "right",
3429              "xtype" : "ColumnModel",
3430              "header" : "Amount",
3431              "width" : 75,
3432              "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3433              "$ xns" : "Roo.grid",
3434              "* prop" : "colModel[]",
3435              "dataIndex" : "gltrans_amount"
3436             },
3437             {
3438              "xtype" : "ColumnModel",
3439              "header" : "Posted",
3440              "width" : 50,
3441              "$ renderer" : "function(v,x,r) { \n    \n    var state = v   ?  '-checked' : '';\n                                    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
3442              "$ xns" : "Roo.grid",
3443              "* prop" : "colModel[]",
3444              "dataIndex" : "gltrans_posted"
3445             }
3446            ]
3447           }
3448          ]
3449         }
3450        ]
3451       }
3452      ]
3453     },
3454     {
3455      "listeners" : {
3456       "|activate" : "function() {\n    _this.profitpanel = this;\n    \n    try { if (MODULE.isBuilder) {\n        return;\n    } } catch(e) { }\n    \n    var id = _this.form.findField('cohead_id').getValue() * 1;\n    if (id < 1) {\n        Roo.MessageBox.alert(\"Save First\", \"Save the order first, before adding items\");\n        _this.dialog.layout.getRegion('center').showPanel(0);\n        return;\n    }\n    \n    if (_this.profitgrid) {\n        _this.profitgrid.footer.onClick('first');\n     }\n    \n}"
3457      },
3458      "background" : true,
3459      "region" : "center",
3460      "fitToframe" : true,
3461      "title" : "Profit",
3462      "xtype" : "GridPanel",
3463      "fitContainer" : true,
3464      "$ xns" : "Roo",
3465      "tableName" : "coitem",
3466      "items" : [
3467       {
3468        "listeners" : {
3469         "|render" : "function() \n{\n    _this.profitgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.profitpanel.active) {\n       this.footer.onClick('first');\n    }\n}"
3470        },
3471        "autoExpandColumn" : "item_number",
3472        "xtype" : "Grid",
3473        "loadMask" : true,
3474        "$ xns" : "Roo.grid",
3475        "* prop" : "grid",
3476        "items" : [
3477         {
3478          "listeners" : {
3479           "beforeload" : "function (_self,o) {\n\n    try {\n       this.removeAll();\n   } catch (e) { }\n   \n\n    if (!_this.data || !_this.data.cohead_id) {\n        return false;\n    }\n    o.params = o.params || {};\n    \n    o.params.coitem_cohead_id = _this.data.cohead_id;\n    o.params._without_list_discount =1;\n    o.params._with_profit = 1;\n    \n}"
3480          },
3481          "xtype" : "Store",
3482          "remoteSort" : true,
3483          "$ sortInfo" : "{ field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' }",
3484          "$ xns" : "Roo.data",
3485          "* prop" : "dataSource",
3486          "items" : [
3487           {
3488            "$ url" : "baseURL + '/Roo/coitem.php'",
3489            "xtype" : "HttpProxy",
3490            "method" : "GET",
3491            "$ xns" : "Roo.data",
3492            "* prop" : "proxy"
3493           },
3494           {
3495            "id" : "id",
3496            "root" : "data",
3497            "xtype" : "JsonReader",
3498            "$ xns" : "Roo.data",
3499            "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'type',\n        'type': 'int'\n    },\n    {\n        'name': 'leader',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_name',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_email',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_role',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_active',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_deleted_by',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_deleted_dt',\n        'type': 'date'\n    },\n    {\n        'name': 'leader_firstname',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_lastname',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_name_facebook',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_url_blog',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_url_twitter',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_url_linkedin',\n        'type': 'string'\n    },\n    {\n        'name': 'leader_crm_lead_percentage',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_crm_industry_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_crm_updated_action_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_crm_created_action_id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader_crm_type_id',\n        'type': 'int'\n    }\n]",
3500            "* prop" : "reader",
3501            "totalProperty" : "total"
3502           }
3503          ]
3504         },
3505         {
3506          "pageSize" : 25,
3507          "xtype" : "PagingToolbar",
3508          "emptyMsg" : "No coitem found",
3509          "$ xns" : "Roo",
3510          "displayMsg" : "Displaying coitem{0} - {1} of {2}",
3511          "displayInfo" : true,
3512          "* prop" : "footer"
3513         },
3514         {
3515          "xtype" : "ColumnModel",
3516          "header" : "Item Code",
3517          "width" : 75,
3518          "$ renderer" : "function(v) { return String.format('{0}', v); }",
3519          "$ xns" : "Roo.grid",
3520          "* prop" : "colModel[]",
3521          "dataIndex" : "item_number"
3522         },
3523         {
3524          "xtype" : "ColumnModel",
3525          "header" : "SubTotal",
3526          "width" : 200,
3527          "$ renderer" : "function(v) {\n\n\n     return Roo.util.Format.number( v, 2);\n  }",
3528          "$ xns" : "Roo.grid",
3529          "* prop" : "colModel[]",
3530          "dataIndex" : "calc_subtotal"
3531         },
3532         {
3533          "xtype" : "ColumnModel",
3534          "header" : "Cost of goods",
3535          "width" : 200,
3536          "$ renderer" : "function(v) {\n\n    return Roo.util.Format.number( v, 2);\n  }",
3537          "$ xns" : "Roo.grid",
3538          "* prop" : "colModel[]",
3539          "dataIndex" : "calc_cost_total"
3540         },
3541         {
3542          "xtype" : "ColumnModel",
3543          "header" : "Profit",
3544          "width" : 200,
3545          "$ renderer" : "function(v,x,r) {\n        \n   var profit = r.data.calc_subtotal - r.data.calc_cost_total;\n   \n   if(parseInt(profit) < 1){\n       return String.format('<b style=\"color:red;\">{0}</b>', Roo.util.Format.number(profit,2));      \n   }\n        \n        \n    return Roo.util.Format.number( profit, 2);\n}",
3546          "$ xns" : "Roo.grid",
3547          "* prop" : "colModel[]",
3548          "dataIndex" : "profit"
3549         }
3550        ]
3551       }
3552      ]
3553     },
3554     {
3555      "listeners" : {
3556       "render" : "function (_self)\n{\n    _this.reversalBtn = _self;\n}",
3557       "click" : "function (_self, e)\n{\n    var id = _this.form.findField('cohead_id').getValue() * 1;\n    \n    if(id < 1){\n        Roo.MessageBox.alert('Error', 'Error occour on getting the sales order id');\n        return;\n    }\n\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure to create a credit memo reversal?\",\n        function (res) {\n            if(res!='yes') {\n                return;\n            \n            }\n            new Pman.Request({\n                method: 'POST',\n                url: baseURL+ '/Roo/cohead',\n                params : {\n                    cohead_id : id,\n                    _cm_reversal : 1\n                },\n                success : function() {\n                    _this.form.load({ method: 'GET', params: { '_id' : id }});\n                }\n            });\n    }); \n      \n}"
3558      },
3559      "text" : "Create CM reversal",
3560      "xtype" : "Button",
3561      "$ xns" : "Roo",
3562      "* prop" : "buttons[]"
3563     },
3564     {
3565      "listeners" : {
3566       "click" : "function (_self, e)\n{\n      if (_this.grid)  _this.grid.stopEditing();\n    _this.dialog.hide();\n}"
3567      },
3568      "text" : "Cancel",
3569      "xtype" : "Button",
3570      "$ xns" : "Roo",
3571      "* prop" : "buttons[]"
3572     },
3573     {
3574      "listeners" : {
3575       "render" : "function (_self)\n{\n    _this.saveBtn = _self;\n}",
3576       "click" : "function (_self, e)\n{\n    // do some checks?\n     \n      if (_this.grid)  _this.grid.stopEditing();\n \n    _this.form.doAction(\"submit\");\n\n}"
3577      },
3578      "text" : "Save",
3579      "xtype" : "Button",
3580      "$ xns" : "Roo",
3581      "* prop" : "buttons[]"
3582     }
3583    ]
3584   }
3585  ]
3586 }