Pman.Dialog.XtupleSalesOrder.bjs
[Pman.Xtuple] / Pman.Dialog.XtupleSalesOrder.bjs
1 {
2     "id": "roo-file-29",
3     "name": "Pman.Dialog.XtupleSalesOrder",
4     "parent": false,
5     "title": "",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtupleSalesOrder.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "|show": "function () {\n       this.layout.getRegion('center').showPanel(0);\n}"
11             },
12             "closable": true,
13             "collapsible": false,
14             "height": 620,
15             "modal": true,
16             "resizable": true,
17             "title": "Edit / Create Sales Order",
18             "width": 1050,
19             "xtype": "LayoutDialog",
20             "|xns": "Roo",
21             "items": [
22                 {
23                     "|xns": "Roo",
24                     "xtype": "LayoutRegion",
25                     "*prop": "center",
26                     "alwaysShowTabs": true,
27                     "tabPosition": "top",
28                     "items": [
29                         {
30                             "|xns": "Roo",
31                             "xtype": "Toolbar",
32                             "*prop": "toolbar",
33                             "items": [
34                                 {
35                                     "|xns": "Roo.Toolbar",
36                                     "xtype": "Fill"
37                                 },
38                                 {
39                                     "listeners": {
40                                         "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}"
41                                     },
42                                     "cls": "x-btn-text-icon",
43                                     "text": "Download Excel",
44                                     "xtype": "Button",
45                                     "|icon": "rootURL + '/Pman/templates/images/spreadsheet.gif'",
46                                     "|xns": "Roo.Toolbar"
47                                 },
48                                 {
49                                     "listeners": {
50                                         "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}"
51                                     },
52                                     "cls": "x-btn-text-icon",
53                                     "text": "Print",
54                                     "xtype": "Button",
55                                     "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
56                                     "|xns": "Roo.Toolbar"
57                                 },
58                                 {
59                                     "listeners": {
60                                         "click": "function (_self, e)\n{\n\n    _this.addShipmentBtn.fireEvent('click');\n   \n}"
61                                     },
62                                     "cls": "x-btn-text-icon",
63                                     "hidden": true,
64                                     "text": "Add Shipment",
65                                     "xtype": "Button",
66                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
67                                     "|xns": "Roo.Toolbar"
68                                 },
69                                 {
70                                     "listeners": {
71                                         "click": "function (_self, e)\n{\n\n   Pman.Dialog.XtupleCustomer.show({\n         cust_id : _this.form.findField('cohead_cust_id').getValue()\n  }); \n}"
72                                     },
73                                     "cls": "x-btn-text-icon",
74                                     "text": "Edit Customer",
75                                     "xtype": "Button",
76                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
77                                     "|xns": "Roo.Toolbar"
78                                 },
79                                 {
80                                     "listeners": {
81                                         "click": "function (_self, e)\n{\n\n        _this.addInvoiceBtn.fireEvent('click');\n   \n}"
82                                     },
83                                     "cls": "x-btn-text-icon",
84                                     "hidden": true,
85                                     "text": "Add Invoice",
86                                     "xtype": "Button",
87                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
88                                     "|xns": "Roo.Toolbar"
89                                 },
90                                 {
91                                     "listeners": {
92                                         "render": "function (_self, e)\n{\n    _this.voidBtn = _self;\n}",
93                                         "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}"
94                                     },
95                                     "text": "Void",
96                                     "xtype": "Button",
97                                     "|xns": "Roo.Toolbar"
98                                 },
99                                 {
100                                     "listeners": {
101                                         "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}",
102                                         "render": "function (_self)\n{\n   _this.closeBtn = _self;\n}"
103                                     },
104                                     "text": "Completed",
105                                     "xtype": "Button",
106                                     "|xns": "Roo.Toolbar"
107                                 }
108                             ]
109                         }
110                     ]
111                 },
112                 {
113                     "listeners": {
114                         "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}"
115                     },
116                     "region": "center",
117                     "title": "Order Details",
118                     "xtype": "ContentPanel",
119                     "|xns": "Roo",
120                     "items": [
121                         {
122                             "listeners": {
123                                 "|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",
124                                 "|rendered": "function (form)\n{\n    _this.form= form;\n}\n",
125                                 "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}"
126                             },
127                             "method": "POST",
128                             "style": "margin:10px;",
129                             "xtype": "Form",
130                             "|url": "baseURL + '/Roo/cohead.php'",
131                             "|xns": "Roo.form",
132                             "items": [
133                                 {
134                                     "xtype": "Column",
135                                     "|xns": "Roo.form",
136                                     "width": "435",
137                                     "items": [
138                                         {
139                                             "labelWidth": 120,
140                                             "legend": "Order",
141                                             "style": "width:420px",
142                                             "xtype": "FieldSet",
143                                             "|xns": "Roo.form",
144                                             "items": [
145                                                 {
146                                                     "labelWidth": 100,
147                                                     "width": 410,
148                                                     "xtype": "Column",
149                                                     "|xns": "Roo.form",
150                                                     "items": [
151                                                         {
152                                                             "labelWidth": 100,
153                                                             "width": 400,
154                                                             "xtype": "Row",
155                                                             "|xns": "Roo.form",
156                                                             "items": [
157                                                                 {
158                                                                     "allowBlank": true,
159                                                                     "emptyText": "Automatic",
160                                                                     "fieldLabel": "Order#",
161                                                                     "name": "cohead_number",
162                                                                     "readOnly": true,
163                                                                     "width": 120,
164                                                                     "xtype": "TextField",
165                                                                     "|xns": "Roo.form"
166                                                                 },
167                                                                 {
168                                                                     "labelWidth": 50,
169                                                                     "style": "float:left",
170                                                                     "width": 150,
171                                                                     "xtype": "Row",
172                                                                     "|xns": "Roo.form",
173                                                                     "items": [
174                                                                         {
175                                                                             "allowBlank": true,
176                                                                             "fieldLabel": "Cust#",
177                                                                             "name": "cohead_cust_id_cust_number",
178                                                                             "readOnly": true,
179                                                                             "width": 110,
180                                                                             "xtype": "TextField",
181                                                                             "|xns": "Roo.form"
182                                                                         }
183                                                                     ]
184                                                                 }
185                                                             ]
186                                                         },
187                                                         {
188                                                             "editable": false,
189                                                             "fieldLabel": "Customer",
190                                                             "forceSelection": true,
191                                                             "hiddenName": "cohead_cust_id",
192                                                             "listWidth": 400,
193                                                             "loadingText": "Searching...",
194                                                             "minChars": 2,
195                                                             "name": "cohead_cust_id_cust_name",
196                                                             "pageSize": 20,
197                                                             "qtip": "Select custinfo",
198                                                             "queryParam": "query[cust_name]",
199                                                             "readOnly": true,
200                                                             "selectOnFocus": true,
201                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{cust_name}</b> </div>",
202                                                             "triggerAction": "all",
203                                                             "typeAhead": true,
204                                                             "valueField": "cust_id",
205                                                             "width": 300,
206                                                             "xtype": "TextField",
207                                                             "|xns": "Roo.form"
208                                                         },
209                                                         {
210                                                             "xtype": "TextField",
211                                                             "|xns": "Roo.form",
212                                                             "fieldLabel": "Customer PO#",
213                                                             "name": "cohead_custponumber",
214                                                             "width": "150"
215                                                         },
216                                                         {
217                                                             "allowBlank": false,
218                                                             "fieldLabel": "Ordered",
219                                                             "format": "Y-m-d",
220                                                             "name": "cohead_orderdate",
221                                                             "width": 100,
222                                                             "xtype": "DateField",
223                                                             "|xns": "Roo.form"
224                                                         },
225                                                         {
226                                                             "labelWidth": 100,
227                                                             "width": 500,
228                                                             "xtype": "Row",
229                                                             "|xns": "Roo.form",
230                                                             "items": [
231                                                                 {
232                                                                     "allowBlank": false,
233                                                                     "fieldLabel": "Target Delivery",
234                                                                     "format": "Y-m-d",
235                                                                     "name": "cohead_targetdate",
236                                                                     "width": 100,
237                                                                     "xtype": "DateField",
238                                                                     "|xns": "Roo.form"
239                                                                 },
240                                                                 {
241                                                                     "hideLabels": true,
242                                                                     "xtype": "Row",
243                                                                     "|xns": "Roo.form",
244                                                                     "items": [
245                                                                         {
246                                                                             "listeners": {
247                                                                                 "check": "function (_self, checked)\n{\n    if(checked){\n        _this.form.findField('cohead_targetdate').setValue(_this.form.findField('cohead_orderdate').getValue());\n    }\n}"
248                                                                             },
249                                                                             "boxLabel": "same as order",
250                                                                             "inputValue": 1,
251                                                                             "name": "_same_as_order",
252                                                                             "xtype": "Checkbox",
253                                                                             "|xns": "Roo.form"
254                                                                         }
255                                                                     ]
256                                                                 }
257                                                             ]
258                                                         },
259                                                         {
260                                                             "allowBlank": false,
261                                                             "displayField": "location_name",
262                                                             "editable": true,
263                                                             "emptyText": "Supply From",
264                                                             "fieldLabel": "Supply From",
265                                                             "forceSelection": true,
266                                                             "hiddenName": "cohead_location_src",
267                                                             "listWidth": 400,
268                                                             "loadingText": "Searching...",
269                                                             "minChars": 2,
270                                                             "name": "cohead_location_src_location_name",
271                                                             "pageSize": 200,
272                                                             "qtip": "Select terms",
273                                                             "queryParam": "query[location_name]",
274                                                             "selectOnFocus": true,
275                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{location_name}</b> {location_descrip} </div>",
276                                                             "triggerAction": "all",
277                                                             "typeAhead": false,
278                                                             "valueField": "location_id",
279                                                             "width": 300,
280                                                             "xtype": "ComboBox",
281                                                             "|xns": "Roo.form",
282                                                             "items": [
283                                                                 {
284                                                                     "listeners": {
285                                                                         "|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"
286                                                                     },
287                                                                     "*prop": "store",
288                                                                     "remoteSort": true,
289                                                                     "xtype": "Store",
290                                                                     "|sortInfo": "{ direction : 'ASC', field: 'location_name' }",
291                                                                     "|xns": "Roo.data",
292                                                                     "items": [
293                                                                         {
294                                                                             "*prop": "proxy",
295                                                                             "method": "GET",
296                                                                             "xtype": "HttpProxy",
297                                                                             "|url": "baseURL + '/Roo/location.php'",
298                                                                             "|xns": "Roo.data"
299                                                                         },
300                                                                         {
301                                                                             "*prop": "reader",
302                                                                             "id": "location_id",
303                                                                             "root": "data",
304                                                                             "totalProperty": "total",
305                                                                             "xtype": "JsonReader",
306                                                                             "|fields": "[{\"name\":\"location_id\",\"type\":\"int\"},\"location_name\"]",
307                                                                             "|xns": "Roo.data"
308                                                                         }
309                                                                     ]
310                                                                 }
311                                                             ]
312                                                         }
313                                                     ]
314                                                 }
315                                             ]
316                                         },
317                                         {
318                                             "labelWidth": 100,
319                                             "legend": "Details",
320                                             "style": "width:420px",
321                                             "xtype": "FieldSet",
322                                             "|xns": "Roo.form",
323                                             "items": [
324                                                 {
325                                                     "labelWidth": 100,
326                                                     "width": 420,
327                                                     "xtype": "Column",
328                                                     "|xns": "Roo.form",
329                                                     "items": [
330                                                         {
331                                                             "|xns": "Roo.form",
332                                                             "xtype": "ComboBox",
333                                                             "allowBlank": false,
334                                                             "editable": false,
335                                                             "emptyText": "Select terms",
336                                                             "forceSelection": true,
337                                                             "listWidth": 400,
338                                                             "loadingText": "Searching...",
339                                                             "minChars": 2,
340                                                             "pageSize": 20,
341                                                             "qtip": "Select terms",
342                                                             "selectOnFocus": true,
343                                                             "triggerAction": "all",
344                                                             "typeAhead": true,
345                                                             "width": 300,
346                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{terms_descrip}</b> </div>",
347                                                             "queryParam": "query[terms_descrip]",
348                                                             "fieldLabel": "Terms",
349                                                             "valueField": "terms_id",
350                                                             "displayField": "terms_descrip",
351                                                             "hiddenName": "cohead_terms_id",
352                                                             "name": "cohead_terms_id_terms_descrip",
353                                                             "items": [
354                                                                 {
355                                                                     "listeners": {
356                                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
357                                                                     },
358                                                                     "*prop": "store",
359                                                                     "remoteSort": true,
360                                                                     "xtype": "Store",
361                                                                     "|sortInfo": "{ direction : 'ASC', field: 'terms_descrip' }",
362                                                                     "|xns": "Roo.data",
363                                                                     "items": [
364                                                                         {
365                                                                             "*prop": "proxy",
366                                                                             "xtype": "HttpProxy",
367                                                                             "method": "GET",
368                                                                             "|xns": "Roo.data",
369                                                                             "|url": "baseURL + '/Roo/terms.php'"
370                                                                         },
371                                                                         {
372                                                                             "*prop": "reader",
373                                                                             "xtype": "JsonReader",
374                                                                             "|xns": "Roo.data",
375                                                                             "id": "terms_id",
376                                                                             "root": "data",
377                                                                             "totalProperty": "total",
378                                                                             "|fields": "[{\"name\":\"terms_id\",\"type\":\"int\"},\"terms_descrip\"]"
379                                                                         }
380                                                                     ]
381                                                                 }
382                                                             ]
383                                                         },
384                                                         {
385                                                             "allowBlank": true,
386                                                             "alwaysQuery": true,
387                                                             "displayField": "salesrep_name",
388                                                             "editable": false,
389                                                             "emptyText": "Select salesrep",
390                                                             "fieldLabel": "Sales Rep",
391                                                             "forceSelection": true,
392                                                             "hiddenName": "cohead_display_salesrep_id",
393                                                             "listWidth": 400,
394                                                             "loadingText": "Searching...",
395                                                             "minChars": 2,
396                                                             "name": "cohead_display_salesrep_id_salesrep_name",
397                                                             "pageSize": 80,
398                                                             "qtip": "Select salesrep",
399                                                             "queryParam": "query[salesrep_name]",
400                                                             "selectOnFocus": true,
401                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>",
402                                                             "triggerAction": "all",
403                                                             "typeAhead": true,
404                                                             "valueField": "salesrep_id",
405                                                             "width": 300,
406                                                             "xtype": "ComboBox",
407                                                             "|xns": "Roo.form",
408                                                             "items": [
409                                                                 {
410                                                                     "listeners": {
411                                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
412                                                                     },
413                                                                     "*prop": "store",
414                                                                     "remoteSort": true,
415                                                                     "xtype": "Store",
416                                                                     "|sortInfo": "{ direction : 'ASC', field: 'salesrep_name' }",
417                                                                     "|xns": "Roo.data",
418                                                                     "items": [
419                                                                         {
420                                                                             "*prop": "proxy",
421                                                                             "xtype": "HttpProxy",
422                                                                             "method": "GET",
423                                                                             "|xns": "Roo.data",
424                                                                             "|url": "baseURL + '/Roo/salesrep.php'"
425                                                                         },
426                                                                         {
427                                                                             "*prop": "reader",
428                                                                             "xtype": "JsonReader",
429                                                                             "|xns": "Roo.data",
430                                                                             "id": "salesrep_id",
431                                                                             "root": "data",
432                                                                             "totalProperty": "total",
433                                                                             "|fields": "[{\"name\":\"salesrep_id\",\"type\":\"int\"},\"salesrep_name\"]"
434                                                                         }
435                                                                     ]
436                                                                 }
437                                                             ]
438                                                         },
439                                                         {
440                                                             "allowBlank": false,
441                                                             "alwaysQuery": true,
442                                                             "displayField": "salesrep_name",
443                                                             "editable": false,
444                                                             "emptyText": "Select Staff",
445                                                             "fieldLabel": "Staff I.C.",
446                                                             "forceSelection": true,
447                                                             "hiddenName": "cohead_salesrep_id",
448                                                             "listWidth": 400,
449                                                             "loadingText": "Searching...",
450                                                             "minChars": 2,
451                                                             "name": "cohead_salesrep_id_salesrep_name",
452                                                             "pageSize": 80,
453                                                             "qtip": "Select salesrep",
454                                                             "queryParam": "query[salesrep_name]",
455                                                             "selectOnFocus": true,
456                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{salesrep_name}</b> </div>",
457                                                             "triggerAction": "all",
458                                                             "typeAhead": true,
459                                                             "valueField": "salesrep_id",
460                                                             "width": 300,
461                                                             "xtype": "ComboBox",
462                                                             "|xns": "Roo.form",
463                                                             "items": [
464                                                                 {
465                                                                     "listeners": {
466                                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
467                                                                     },
468                                                                     "*prop": "store",
469                                                                     "remoteSort": true,
470                                                                     "xtype": "Store",
471                                                                     "|sortInfo": "{ direction : 'ASC', field: 'salesrep_name' }",
472                                                                     "|xns": "Roo.data",
473                                                                     "items": [
474                                                                         {
475                                                                             "*prop": "proxy",
476                                                                             "xtype": "HttpProxy",
477                                                                             "method": "GET",
478                                                                             "|xns": "Roo.data",
479                                                                             "|url": "baseURL + '/Roo/salesrep.php'"
480                                                                         },
481                                                                         {
482                                                                             "*prop": "reader",
483                                                                             "xtype": "JsonReader",
484                                                                             "|xns": "Roo.data",
485                                                                             "id": "salesrep_id",
486                                                                             "root": "data",
487                                                                             "totalProperty": "total",
488                                                                             "|fields": "[{\"name\":\"salesrep_id\",\"type\":\"int\"},\"salesrep_name\"]"
489                                                                         }
490                                                                     ]
491                                                                 }
492                                                             ]
493                                                         },
494                                                         {
495                                                             "fieldLabel": "Order Comments",
496                                                             "height": 80,
497                                                             "name": "cohead_ordercomments",
498                                                             "width": 300,
499                                                             "xtype": "TextArea",
500                                                             "|xns": "Roo.form"
501                                                         }
502                                                     ]
503                                                 }
504                                             ]
505                                         },
506                                         {
507                                             "xtype": "FieldSet",
508                                             "|xns": "Roo.form",
509                                             "style": "width:420px",
510                                             "legend": "Billing",
511                                             "items": [
512                                                 {
513                                                     "xtype": "Column",
514                                                     "|xns": "Roo.form",
515                                                     "width": "420",
516                                                     "labelWidth": "50",
517                                                     "items": [
518                                                         {
519                                                             "listeners": {
520                                                                 "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}",
521                                                                 "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}"
522                                                             },
523                                                             "allowBlank": false,
524                                                             "alwaysQuery": true,
525                                                             "displayField": "cntct_name",
526                                                             "editable": true,
527                                                             "emptyText": "Select cntct",
528                                                             "fieldLabel": "Bill To (select)",
529                                                             "forceSelection": true,
530                                                             "hiddenName": "cohead_billto_cntct_id",
531                                                             "listWidth": 400,
532                                                             "loadingText": "Searching...",
533                                                             "minChars": 2,
534                                                             "name": "cohead_billto_cntct_id_cntct_name",
535                                                             "pageSize": 20,
536                                                             "qtip": "Select cntct",
537                                                             "queryParam": "query[cntct_name]",
538                                                             "selectOnFocus": true,
539                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{cntct_name}</b> {cntct_addr_id_addr_line1}</div>",
540                                                             "triggerAction": "all",
541                                                             "typeAhead": true,
542                                                             "valueField": "cntct_id",
543                                                             "width": 300,
544                                                             "xtype": "ComboBox",
545                                                             "|xns": "Roo.form",
546                                                             "items": [
547                                                                 {
548                                                                     "listeners": {
549                                                                         "|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"
550                                                                     },
551                                                                     "*prop": "store",
552                                                                     "remoteSort": true,
553                                                                     "xtype": "Store",
554                                                                     "|sortInfo": "{ direction : 'ASC', field: 'cntct_name' }",
555                                                                     "|xns": "Roo.data",
556                                                                     "items": [
557                                                                         {
558                                                                             "*prop": "proxy",
559                                                                             "xtype": "HttpProxy",
560                                                                             "method": "GET",
561                                                                             "|xns": "Roo.data",
562                                                                             "|url": "baseURL + '/Roo/cntct.php'"
563                                                                         },
564                                                                         {
565                                                                             "*prop": "reader",
566                                                                             "xtype": "JsonReader",
567                                                                             "|xns": "Roo.data",
568                                                                             "id": "cntct_id",
569                                                                             "root": "data",
570                                                                             "totalProperty": "total",
571                                                                             "|fields": "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]"
572                                                                         }
573                                                                     ]
574                                                                 }
575                                                             ]
576                                                         },
577                                                         {
578                                                             "listeners": {
579                                                                 "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}"
580                                                             },
581                                                             "fieldLabel": "or enter Address",
582                                                             "name": "billto_address",
583                                                             "readOnly": true,
584                                                             "xtype": "TextArea",
585                                                             "|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",
586                                                             "|xns": "Roo.form"
587                                                         },
588                                                         {
589                                                             "fieldLabel": "Email",
590                                                             "name": "billto_email",
591                                                             "xtype": "DisplayField",
592                                                             "|valueRenderer": "function(v)\n{\n \n    return v ? String.format('<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>',v) : '';\n}",
593                                                             "|xns": "Roo.form"
594                                                         }
595                                                     ]
596                                                 }
597                                             ]
598                                         }
599                                     ]
600                                 },
601                                 {
602                                     "xtype": "Column",
603                                     "|xns": "Roo.form",
604                                     "width": "435",
605                                     "style": "margin-left:10px",
606                                     "items": [
607                                         {
608                                             "xtype": "FieldSet",
609                                             "|xns": "Roo.form",
610                                             "legend": "Price Details",
611                                             "style": "width:420px",
612                                             "labelWidth": "50",
613                                             "items": [
614                                                 {
615                                                     "labelAlign": "right",
616                                                     "labelWidth": 300,
617                                                     "width": 420,
618                                                     "xtype": "Column",
619                                                     "|xns": "Roo.form",
620                                                     "items": [
621                                                         {
622                                                             "labelAlign": "top",
623                                                             "labelSeparator": "&nbsp;",
624                                                             "width": 500,
625                                                             "xtype": "Row",
626                                                             "|xns": "Roo.form",
627                                                             "items": [
628                                                                 {
629                                                                     "listeners": {
630                                                                         "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}"
631                                                                     },
632                                                                     "allowBlank": false,
633                                                                     "displayField": "curr_name",
634                                                                     "editable": false,
635                                                                     "emptyText": "Select curr_name",
636                                                                     "fieldLabel": "Currency",
637                                                                     "forceSelection": true,
638                                                                     "hiddenName": "cohead_curr_id",
639                                                                     "listWidth": 400,
640                                                                     "loadingText": "Searching...",
641                                                                     "minChars": 2,
642                                                                     "name": "cohead_curr_id_curr_name",
643                                                                     "pageSize": 20,
644                                                                     "qtip": "Select Currency",
645                                                                     "queryParam": "query[curr_name]",
646                                                                     "selectOnFocus": true,
647                                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{curr_name}</b> </div>",
648                                                                     "triggerAction": "all",
649                                                                     "typeAhead": true,
650                                                                     "valueField": "curr_id",
651                                                                     "width": 285,
652                                                                     "xtype": "ComboBox",
653                                                                     "|xns": "Roo.form",
654                                                                     "items": [
655                                                                         {
656                                                                             "listeners": {
657                                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n   \n}\n"
658                                                                             },
659                                                                             "*prop": "store",
660                                                                             "remoteSort": true,
661                                                                             "xtype": "Store",
662                                                                             "|sortInfo": "{ direction : 'ASC', field: 'curr_symbol' }",
663                                                                             "|xns": "Roo.data",
664                                                                             "items": [
665                                                                                 {
666                                                                                     "*prop": "proxy",
667                                                                                     "xtype": "HttpProxy",
668                                                                                     "method": "GET",
669                                                                                     "|xns": "Roo.data",
670                                                                                     "|url": "baseURL + '/Roo/curr_symbol.php'"
671                                                                                 },
672                                                                                 {
673                                                                                     "*prop": "reader",
674                                                                                     "xtype": "JsonReader",
675                                                                                     "|xns": "Roo.data",
676                                                                                     "id": "curr_id",
677                                                                                     "root": "data",
678                                                                                     "totalProperty": "total",
679                                                                                     "|fields": "[{\"name\":\"curr_id\",\"type\":\"int\"},\"curr_symbol\"]"
680                                                                                 }
681                                                                             ]
682                                                                         }
683                                                                     ]
684                                                                 },
685                                                                 {
686                                                                     "allowDecimals": true,
687                                                                     "cls": "roo-align-right",
688                                                                     "decimalPrecision": 3,
689                                                                     "fieldLabel": "Products",
690                                                                     "name": "cohead_subtotal",
691                                                                     "readOnly": true,
692                                                                     "width": 100,
693                                                                     "xtype": "NumberField",
694                                                                     "|xns": "Roo.form"
695                                                                 }
696                                                             ]
697                                                         },
698                                                         {
699                                                             "labelAlign": "top",
700                                                             "labelSeparator": "&nbsp;",
701                                                             "width": 500,
702                                                             "xtype": "Row",
703                                                             "|xns": "Roo.form",
704                                                             "items": [
705                                                                 {
706                                                                     "listeners": {
707                                                                         "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}"
708                                                                     },
709                                                                     "allowBlank": false,
710                                                                     "displayField": "taxzone_descrip",
711                                                                     "editable": false,
712                                                                     "emptyText": "Select taxtype",
713                                                                     "fieldLabel": "Tax Zone",
714                                                                     "forceSelection": true,
715                                                                     "hiddenName": "cohead_taxzone_id",
716                                                                     "listWidth": 400,
717                                                                     "loadingText": "Searching...",
718                                                                     "minChars": 2,
719                                                                     "name": "cohead_taxzone_id_taxzone_descrip",
720                                                                     "pageSize": 20,
721                                                                     "qtip": "Select taxtype",
722                                                                     "queryParam": "query[taxzone_descrip]",
723                                                                     "selectOnFocus": true,
724                                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{taxzone_descrip}</b> </div>",
725                                                                     "triggerAction": "all",
726                                                                     "typeAhead": true,
727                                                                     "valueField": "taxzone_id",
728                                                                     "width": 285,
729                                                                     "xtype": "ComboBox",
730                                                                     "|xns": "Roo.form",
731                                                                     "items": [
732                                                                         {
733                                                                             "listeners": {
734                                                                                 "|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"
735                                                                             },
736                                                                             "*prop": "store",
737                                                                             "remoteSort": true,
738                                                                             "xtype": "Store",
739                                                                             "|sortInfo": "{ direction : 'ASC', field: 'taxzone_descrip' }",
740                                                                             "|xns": "Roo.data",
741                                                                             "items": [
742                                                                                 {
743                                                                                     "*prop": "proxy",
744                                                                                     "method": "GET",
745                                                                                     "xtype": "HttpProxy",
746                                                                                     "|url": "baseURL + '/Roo/taxzone.php'",
747                                                                                     "|xns": "Roo.data"
748                                                                                 },
749                                                                                 {
750                                                                                     "*prop": "reader",
751                                                                                     "id": "taxzone_id",
752                                                                                     "root": "data",
753                                                                                     "totalProperty": "total",
754                                                                                     "xtype": "JsonReader",
755                                                                                     "|fields": "[{\"name\":\"taxzone_id\",\"type\":\"int\"},\"taxzone_descrip\"]",
756                                                                                     "|xns": "Roo.data"
757                                                                                 }
758                                                                             ]
759                                                                         }
760                                                                     ]
761                                                                 },
762                                                                 {
763                                                                     "allowDecimals": true,
764                                                                     "cls": "roo-align-right",
765                                                                     "decimalPrecision": 3,
766                                                                     "fieldLabel": "Tax",
767                                                                     "name": "cohead_tax",
768                                                                     "readOnly": true,
769                                                                     "width": 100,
770                                                                     "xtype": "NumberField",
771                                                                     "|xns": "Roo.form"
772                                                                 }
773                                                             ]
774                                                         },
775                                                         {
776                                                             "allowDecimals": true,
777                                                             "cls": "roo-align-right",
778                                                             "decimalPrecision": 3,
779                                                             "fieldLabel": "Pre Tax discount",
780                                                             "name": "cohead_pretax_discount",
781                                                             "readOnly": true,
782                                                             "width": 100,
783                                                             "xtype": "NumberField",
784                                                             "|xns": "Roo.form"
785                                                         },
786                                                         {
787                                                             "labelAlign": "top",
788                                                             "labelSeparator": "&nbsp;",
789                                                             "width": 500,
790                                                             "xtype": "Row",
791                                                             "|xns": "Roo.form",
792                                                             "items": [
793                                                                 {
794                                                                     "fieldLabel": "Discount after Tax  Description",
795                                                                     "name": "cohead_misc_descrip",
796                                                                     "width": 230,
797                                                                     "xtype": "TextField",
798                                                                     "|xns": "Roo.form"
799                                                                 },
800                                                                 {
801                                                                     "listeners": {
802                                                                         "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}"
803                                                                     },
804                                                                     "allowDecimals": true,
805                                                                     "cls": "roo-align-right",
806                                                                     "decimalPrecision": 1,
807                                                                     "fieldLabel": "%",
808                                                                     "name": "cohead_misc_per",
809                                                                     "width": 35,
810                                                                     "xtype": "NumberField",
811                                                                     "|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",
812                                                                     "|xns": "Roo.form"
813                                                                 },
814                                                                 {
815                                                                     "listeners": {
816                                                                         "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}"
817                                                                     },
818                                                                     "allowDecimals": true,
819                                                                     "cls": "roo-align-right",
820                                                                     "decimalPrecision": 3,
821                                                                     "fieldLabel": "&nbsp;",
822                                                                     "name": "cohead_posttax_discount",
823                                                                     "width": 100,
824                                                                     "xtype": "NumberField",
825                                                                     "|xns": "Roo.form"
826                                                                 }
827                                                             ]
828                                                         },
829                                                         {
830                                                             "allowDecimals": true,
831                                                             "cls": "roo-align-right",
832                                                             "decimalPrecision": 3,
833                                                             "fieldLabel": "Total",
834                                                             "name": "cohead_total",
835                                                             "readOnly": true,
836                                                             "width": 100,
837                                                             "xtype": "NumberField",
838                                                             "|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",
839                                                             "|xns": "Roo.form"
840                                                         },
841                                                         {
842                                                             "listeners": {
843                                                                 "keyup": "function (_self, e)\n{\n    _this.form.findField('cohead_total').recalc();\n}"
844                                                             },
845                                                             "allowDecimals": true,
846                                                             "cls": "roo-align-right",
847                                                             "decimalPrecision": 3,
848                                                             "fieldLabel": "Shipping",
849                                                             "name": "cohead_freight",
850                                                             "width": 100,
851                                                             "xtype": "NumberField",
852                                                             "|xns": "Roo.form"
853                                                         },
854                                                         {
855                                                             "allowDecimals": true,
856                                                             "cls": "roo-align-right",
857                                                             "decimalPrecision": 3,
858                                                             "fieldLabel": "Unshipped Total",
859                                                             "name": "cohead_unshipped",
860                                                             "readOnly": true,
861                                                             "width": 100,
862                                                             "xtype": "NumberField",
863                                                             "|xns": "Roo.form"
864                                                         },
865                                                         {
866                                                             "allowDecimals": true,
867                                                             "cls": "roo-align-right",
868                                                             "decimalPrecision": 3,
869                                                             "fieldLabel": "Uninvoiced Total",
870                                                             "name": "cohead_uninvoiced",
871                                                             "readOnly": true,
872                                                             "width": 100,
873                                                             "xtype": "NumberField",
874                                                             "|xns": "Roo.form"
875                                                         }
876                                                     ]
877                                                 }
878                                             ]
879                                         },
880                                         {
881                                             "xtype": "FieldSet",
882                                             "|xns": "Roo.form",
883                                             "style": "width:420px",
884                                             "legend": "Shipping",
885                                             "items": [
886                                                 {
887                                                     "xtype": "Column",
888                                                     "|xns": "Roo.form",
889                                                     "width": "420",
890                                                     "labelWidth": "50",
891                                                     "items": [
892                                                         {
893                                                             "labelSeparator": "&nbsp;",
894                                                             "xtype": "Row",
895                                                             "|xns": "Roo.form",
896                                                             "items": [
897                                                                 {
898                                                                     "listeners": {
899                                                                         "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}"
900                                                                     },
901                                                                     "boxLabel": "Same as Billing",
902                                                                     "name": "_shipto_same",
903                                                                     "xtype": "Checkbox",
904                                                                     "|xns": "Roo.form"
905                                                                 }
906                                                             ]
907                                                         },
908                                                         {
909                                                             "listeners": {
910                                                                 "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}",
911                                                                 "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}"
912                                                             },
913                                                             "allowBlank": false,
914                                                             "alwaysQuery": true,
915                                                             "displayField": "cntct_name",
916                                                             "editable": true,
917                                                             "emptyText": "Select ship to",
918                                                             "fieldLabel": "Ship to",
919                                                             "forceSelection": true,
920                                                             "hiddenName": "cohead_shipto_cntct_id",
921                                                             "listWidth": 400,
922                                                             "loadingText": "Searching...",
923                                                             "minChars": 2,
924                                                             "name": "cohead_shipto_cntct_id_cntct_name",
925                                                             "pageSize": 20,
926                                                             "qtip": "Select shiptoinfo",
927                                                             "queryParam": "query[cntct_name]",
928                                                             "selectOnFocus": true,
929                                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\">{cntct_name} - <b>{cntct_addr_id_addr_line1}</b> </div>",
930                                                             "triggerAction": "all",
931                                                             "typeAhead": true,
932                                                             "valueField": "cntct_id",
933                                                             "width": 300,
934                                                             "xtype": "ComboBox",
935                                                             "|xns": "Roo.form",
936                                                             "items": [
937                                                                 {
938                                                                     "listeners": {
939                                                                         "|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"
940                                                                     },
941                                                                     "*prop": "store",
942                                                                     "remoteSort": true,
943                                                                     "xtype": "Store",
944                                                                     "|sortInfo": "{ direction : 'ASC', field: 'cntct_name' }",
945                                                                     "|xns": "Roo.data",
946                                                                     "items": [
947                                                                         {
948                                                                             "*prop": "proxy",
949                                                                             "xtype": "HttpProxy",
950                                                                             "method": "GET",
951                                                                             "|xns": "Roo.data",
952                                                                             "|url": "baseURL + '/Roo/cntct.php'"
953                                                                         },
954                                                                         {
955                                                                             "*prop": "reader",
956                                                                             "xtype": "JsonReader",
957                                                                             "|xns": "Roo.data",
958                                                                             "id": "cntct_id",
959                                                                             "root": "data",
960                                                                             "totalProperty": "total",
961                                                                             "|fields": "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]"
962                                                                         }
963                                                                     ]
964                                                                 }
965                                                             ]
966                                                         },
967                                                         {
968                                                             "listeners": {
969                                                                 "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}"
970                                                             },
971                                                             "fieldLabel": "Address",
972                                                             "name": "shipto_address",
973                                                             "readOnly": true,
974                                                             "width": 300,
975                                                             "xtype": "TextArea",
976                                                             "|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_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",
977                                                             "|xns": "Roo.form"
978                                                         },
979                                                         {
980                                                             "xtype": "TextArea",
981                                                             "|xns": "Roo.form",
982                                                             "fieldLabel": "Shipment Comments",
983                                                             "name": "cohead_shipcomments",
984                                                             "width": 300
985                                                         }
986                                                     ]
987                                                 }
988                                             ]
989                                         }
990                                     ]
991                                 },
992                                 {
993                                     "name": "cohead_id",
994                                     "xtype": "Hidden",
995                                     "|xns": "Roo.form"
996                                 },
997                                 {
998                                     "name": "cohead_shipto_id",
999                                     "xtype": "Hidden",
1000                                     "|xns": "Roo.form"
1001                                 },
1002                                 {
1003                                     "name": "cohead_shipto_id_shipto_name",
1004                                     "xtype": "Hidden",
1005                                     "|xns": "Roo.form"
1006                                 },
1007                                 {
1008                                     "name": "cohead_max_linenumber",
1009                                     "xtype": "Hidden",
1010                                     "|xns": "Roo.form"
1011                                 },
1012                                 {
1013                                     "name": "cohead_cust_id",
1014                                     "xtype": "Hidden",
1015                                     "|xns": "Roo.form"
1016                                 },
1017                                 {
1018                                     "name": "cohead_misc",
1019                                     "xtype": "Hidden",
1020                                     "|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",
1021                                     "|xns": "Roo.form"
1022                                 },
1023                                 {
1024                                     "name": "taxzone_rate",
1025                                     "xtype": "Hidden",
1026                                     "|xns": "Roo.form"
1027                                 }
1028                             ]
1029                         }
1030                     ]
1031                 },
1032                 {
1033                     "listeners": {
1034                         "|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}",
1035                         "deactivate": "function (_self)\n{\n    if(_this.grid){\n        _this.grid.stopEditing();\n    }\n}"
1036                     },
1037                     "background": true,
1038                     "fitContainer": true,
1039                     "fitToframe": true,
1040                     "region": "center",
1041                     "tableName": "coitem",
1042                     "title": "Order Items",
1043                     "xtype": "GridPanel",
1044                     "|xns": "Roo",
1045                     "items": [
1046                         {
1047                             "listeners": {
1048                                 "|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}",
1049                                 "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",
1050                                 "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}",
1051                                 "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}",
1052                                 "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}"
1053                             },
1054                             "*prop": "grid",
1055                             "autoExpandColumn": "item_descrip1",
1056                             "clicksToEdit": 1,
1057                             "loadMask": true,
1058                             "xtype": "EditorGrid",
1059                             "|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",
1060                             "|xns": "Roo.grid",
1061                             "items": [
1062                                 {
1063                                     "listeners": {
1064                                         "tabend": "function (_self)\n{\n    _this.addItemBtn.fireEvent('click', _this.addItemBtn);\n}",
1065                                         "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}"
1066                                     },
1067                                     "*prop": "sm",
1068                                     "enter_is_tab": true,
1069                                     "xtype": "CellSelectionModel",
1070                                     "|xns": "Roo.grid"
1071                                 },
1072                                 {
1073                                     "*prop": "footer",
1074                                     "displayInfo": true,
1075                                     "emptyMsg": "No Items",
1076                                     "pageSize": 100,
1077                                     "xtype": "PagingToolbar",
1078                                     "|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",
1079                                     "|xns": "Roo",
1080                                     "items": [
1081                                         {
1082                                             "listeners": {
1083                                                 "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}"
1084                                             },
1085                                             "text": "Fill empty Ship To",
1086                                             "xtype": "Button",
1087                                             "|xns": "Roo.Toolbar"
1088                                         },
1089                                         {
1090                                             "listeners": {
1091                                                 "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}"
1092                                             },
1093                                             "text": "Update Location to match S/O",
1094                                             "xtype": "Button",
1095                                             "|xns": "Roo.Toolbar"
1096                                         },
1097                                         {
1098                                             "listeners": {
1099                                                 "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}",
1100                                                 "render": "function (_self)\n{\n    _this.showgstBtn = _self;\n}"
1101                                             },
1102                                             "enableToggle": true,
1103                                             "minWidth": 100,
1104                                             "text": "Prices with GST",
1105                                             "xtype": "Button",
1106                                             "|xns": "Roo.Toolbar"
1107                                         }
1108                                     ]
1109                                 },
1110                                 {
1111                                     "listeners": {
1112                                         "|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}",
1113                                         "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  ",
1114                                         "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}"
1115                                     },
1116                                     "*prop": "dataSource",
1117                                     "remoteSort": true,
1118                                     "xtype": "Store",
1119                                     "|sortInfo": "{ field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' }",
1120                                     "|xns": "Roo.data",
1121                                     "items": [
1122                                         {
1123                                             "*prop": "proxy",
1124                                             "method": "GET",
1125                                             "xtype": "HttpProxy",
1126                                             "|url": "baseURL + '/Roo/coitem.php'",
1127                                             "|xns": "Roo.data"
1128                                         },
1129                                         {
1130                                             "*prop": "reader",
1131                                             ".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\"}",
1132                                             "id": "coitem_id",
1133                                             "root": "data",
1134                                             "totalProperty": "total",
1135                                             "xtype": "JsonReader",
1136                                             "|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]",
1137                                             "|xns": "Roo.data"
1138                                         }
1139                                     ]
1140                                 },
1141                                 {
1142                                     "*prop": "toolbar",
1143                                     "xtype": "Toolbar",
1144                                     "|xns": "Roo",
1145                                     "items": [
1146                                         {
1147                                             "listeners": {
1148                                                 "|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",
1149                                                 "render": "function (_self)\n{\n    _this.addItemBtn = _self;\n}"
1150                                             },
1151                                             "cls": "x-btn-text-icon",
1152                                             "text": "Add",
1153                                             "xtype": "Button",
1154                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
1155                                             "|xns": "Roo.Toolbar"
1156                                         },
1157                                         {
1158                                             "listeners": {
1159                                                 "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}"
1160                                             },
1161                                             "cls": "x-btn-text-icon",
1162                                             "text": "Find Products",
1163                                             "xtype": "Button",
1164                                             "|icon": "rootURL + '/Pman/templates/images/search.gif'",
1165                                             "|xns": "Roo.Toolbar"
1166                                         },
1167                                         {
1168                                             "listeners": {
1169                                                 "|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",
1170                                                 "render": "function (_self)\n{\n    _this.xferAll  = _self;\n}"
1171                                             },
1172                                             "cls": "x-btn-text-icon",
1173                                             "hidden": true,
1174                                             "text": "Xfer all stock to HK",
1175                                             "xtype": "Button",
1176                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
1177                                             "|xns": "Roo.Toolbar"
1178                                         },
1179                                         {
1180                                             "listeners": {
1181                                                 "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}"
1182                                             },
1183                                             "text": "Show Inventory History",
1184                                             "xtype": "Button",
1185                                             "|xns": "Roo.Toolbar"
1186                                         },
1187                                         {
1188                                             "|xns": "Roo.Toolbar",
1189                                             "xtype": "Separator"
1190                                         },
1191                                         {
1192                                             "text": "Apply % Discount of : ",
1193                                             "xtype": "TextItem",
1194                                             "|xns": "Roo.Toolbar"
1195                                         },
1196                                         {
1197                                             "listeners": {
1198                                                 "render": "function (_self)\n{\n    _this._applyDiscount = _self;\n}"
1199                                             },
1200                                             "width": 40,
1201                                             "xtype": "TextField",
1202                                             "|xns": "Roo.form"
1203                                         },
1204                                         {
1205                                             "listeners": {
1206                                                 "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}"
1207                                             },
1208                                             "text": "Apply To All",
1209                                             "xtype": "Button",
1210                                             "|xns": "Roo.Toolbar"
1211                                         },
1212                                         {
1213                                             "listeners": {
1214                                                 "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}"
1215                                             },
1216                                             "text": "Import",
1217                                             "xtype": "Button",
1218                                             "|xns": "Roo.Toolbar"
1219                                         },
1220                                         {
1221                                             "xtype": "Fill",
1222                                             "|xns": "Roo.Toolbar"
1223                                         },
1224                                         {
1225                                             "listeners": {
1226                                                 "|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        "
1227                                             },
1228                                             "cls": "x-btn-text-icon",
1229                                             "text": "Delete",
1230                                             "xtype": "Button",
1231                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1232                                             "|xns": "Roo.Toolbar"
1233                                         },
1234                                         {
1235                                             "listeners": {
1236                                                 "|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        "
1237                                             },
1238                                             "cls": "x-btn-text-icon",
1239                                             "text": "Delete All",
1240                                             "xtype": "Button",
1241                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1242                                             "|xns": "Roo.Toolbar"
1243                                         }
1244                                     ]
1245                                 },
1246                                 {
1247                                     "*prop": "colModel[]",
1248                                     ".builderCfg": "{\"table\":\"coitem\",\"column\":\"coitem_linenumber\",\"columnshort\":\"coitem_linenumber\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Item#\"}",
1249                                     "dataIndex": "coitem_linenumber",
1250                                     "header": "Item#",
1251                                     "width": 40,
1252                                     "xtype": "ColumnModel",
1253                                     "|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  }",
1254                                     "|xns": "Roo.grid"
1255                                 },
1256                                 {
1257                                     "*prop": "colModel[]",
1258                                     "dataIndex": "item_number",
1259                                     "header": "Item Code",
1260                                     "width": 75,
1261                                     "xtype": "ColumnModel",
1262                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1263                                     "|xns": "Roo.grid",
1264                                     "items": [
1265                                         {
1266                                             "|xns": "Roo.grid",
1267                                             "xtype": "GridEditor",
1268                                             "*prop": "editor",
1269                                             "items": [
1270                                                 {
1271                                                     "listeners": {
1272                                                         "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}"
1273                                                     },
1274                                                     "*prop": "field",
1275                                                     "allowBlank": false,
1276                                                     "displayField": "itemsite_item_id_item_number",
1277                                                     "editable": true,
1278                                                     "emptyText": "Select item",
1279                                                     "forceSelection": true,
1280                                                     "hiddenName": "itemsite_item_id_item_number",
1281                                                     "listWidth": 400,
1282                                                     "loadingText": "Searching...",
1283                                                     "minChars": 2,
1284                                                     "name": "item_number",
1285                                                     "pageSize": 20,
1286                                                     "qtip": "Select item",
1287                                                     "queryParam": "query[number]",
1288                                                     "selectOnFocus": true,
1289                                                     "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>",
1290                                                     "triggerAction": "all",
1291                                                     "typeAhead": false,
1292                                                     "valueField": "item_number",
1293                                                     "xtype": "ComboBox",
1294                                                     "|xns": "Roo.form",
1295                                                     "items": [
1296                                                         {
1297                                                             "listeners": {
1298                                                                 "|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"
1299                                                             },
1300                                                             "*prop": "store",
1301                                                             "remoteSort": true,
1302                                                             "xtype": "Store",
1303                                                             "|sortInfo": "{ direction : 'ASC', field: 'item_number' }",
1304                                                             "|xns": "Roo.data",
1305                                                             "items": [
1306                                                                 {
1307                                                                     "*prop": "proxy",
1308                                                                     "method": "GET",
1309                                                                     "xtype": "HttpProxy",
1310                                                                     "|url": "baseURL + '/Roo/itemsite.php'",
1311                                                                     "|xns": "Roo.data"
1312                                                                 },
1313                                                                 {
1314                                                                     "*prop": "reader",
1315                                                                     "id": "shipto_id",
1316                                                                     "root": "data",
1317                                                                     "totalProperty": "total",
1318                                                                     "xtype": "JsonReader",
1319                                                                     "|fields": "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]",
1320                                                                     "|xns": "Roo.data"
1321                                                                 }
1322                                                             ]
1323                                                         }
1324                                                     ]
1325                                                 }
1326                                             ]
1327                                         }
1328                                     ]
1329                                 },
1330                                 {
1331                                     "*prop": "colModel[]",
1332                                     "dataIndex": "coitem_location_src",
1333                                     "header": "From",
1334                                     "width": 75,
1335                                     "xtype": "ColumnModel",
1336                                     "|renderer": "function(v,x,r) { \n    return String.format('{0}', r.data.coitem_location_src_location_name); \n}",
1337                                     "|xns": "Roo.grid",
1338                                     "items": [
1339                                         {
1340                                             "*prop": "editor",
1341                                             "xtype": "GridEditor",
1342                                             "|xns": "Roo.grid",
1343                                             "items": [
1344                                                 {
1345                                                     "listeners": {
1346                                                         "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}"
1347                                                     },
1348                                                     "*prop": "field",
1349                                                     "allowBlank": false,
1350                                                     "alwaysQuery": true,
1351                                                     "displayField": "location_name",
1352                                                     "editable": true,
1353                                                     "emptyText": "Select location",
1354                                                     "forceSelection": true,
1355                                                     "hiddenName": "coitem_location_src",
1356                                                     "listWidth": 400,
1357                                                     "loadingText": "Searching...",
1358                                                     "minChars": 2,
1359                                                     "name": "coitem_location_src_location_name",
1360                                                     "pageSize": 20,
1361                                                     "qtip": "Select item",
1362                                                     "queryParam": "query[location_name]",
1363                                                     "selectOnFocus": true,
1364                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b> {location_name}</b> {location_descrip}</div>",
1365                                                     "triggerAction": "all",
1366                                                     "typeAhead": false,
1367                                                     "valueField": "location_id",
1368                                                     "xtype": "ComboBox",
1369                                                     "|xns": "Roo.form",
1370                                                     "items": [
1371                                                         {
1372                                                             "listeners": {
1373                                                                 "|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"
1374                                                             },
1375                                                             "*prop": "store",
1376                                                             "remoteSort": true,
1377                                                             "xtype": "Store",
1378                                                             "|sortInfo": "{ direction : 'ASC', field: 'location_name' }",
1379                                                             "|xns": "Roo.data",
1380                                                             "items": [
1381                                                                 {
1382                                                                     "*prop": "proxy",
1383                                                                     "method": "GET",
1384                                                                     "xtype": "HttpProxy",
1385                                                                     "|url": "baseURL + '/Roo/location.php'",
1386                                                                     "|xns": "Roo.data"
1387                                                                 },
1388                                                                 {
1389                                                                     "*prop": "reader",
1390                                                                     "id": "shipto_id",
1391                                                                     "root": "data",
1392                                                                     "totalProperty": "total",
1393                                                                     "xtype": "JsonReader",
1394                                                                     "|fields": "[{\"name\":\"location_id\",\"type\":\"int\"},\"location_name\"]",
1395                                                                     "|xns": "Roo.data"
1396                                                                 }
1397                                                             ]
1398                                                         }
1399                                                     ]
1400                                                 }
1401                                             ]
1402                                         }
1403                                     ]
1404                                 },
1405                                 {
1406                                     "*prop": "colModel[]",
1407                                     "dataIndex": "coitem_shipto_id",
1408                                     "header": "To",
1409                                     "width": 75,
1410                                     "xtype": "ColumnModel",
1411                                     "|renderer": "function(v,x,r) { \n    return String.format('{0}:{1}', v, r.data.coitem_shipto_id_shipto_name); \n}",
1412                                     "|xns": "Roo.grid",
1413                                     "items": [
1414                                         {
1415                                             "|xns": "Roo.grid",
1416                                             "xtype": "GridEditor",
1417                                             "*prop": "editor",
1418                                             "items": [
1419                                                 {
1420                                                     "listeners": {
1421                                                         "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}",
1422                                                         "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}"
1423                                                     },
1424                                                     "*prop": "field",
1425                                                     "allowBlank": false,
1426                                                     "alwaysQuery": true,
1427                                                     "displayField": "shipto_name",
1428                                                     "editable": false,
1429                                                     "emptyText": "Select cntct",
1430                                                     "forceSelection": true,
1431                                                     "hiddenName": "cohead_shipto_id",
1432                                                     "listWidth": 400,
1433                                                     "loadingText": "Searching...",
1434                                                     "minChars": 2,
1435                                                     "name": "coitem_shipto_id_shipto_name",
1436                                                     "pageSize": 20,
1437                                                     "qtip": "Select shipto",
1438                                                     "queryParam": "query[shipto_name]",
1439                                                     "selectOnFocus": true,
1440                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{shipto_id}:{shipto_addr_id_addr_name}</b> </div>",
1441                                                     "triggerAction": "all",
1442                                                     "typeAhead": false,
1443                                                     "valueField": "shipto_id",
1444                                                     "width": 300,
1445                                                     "xtype": "ComboBox",
1446                                                     "|xns": "Roo.form",
1447                                                     "items": [
1448                                                         {
1449                                                             "listeners": {
1450                                                                 "|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"
1451                                                             },
1452                                                             "*prop": "store",
1453                                                             "remoteSort": true,
1454                                                             "xtype": "Store",
1455                                                             "|sortInfo": "{ direction : 'ASC', field: 'shipto_name' }",
1456                                                             "|xns": "Roo.data",
1457                                                             "items": [
1458                                                                 {
1459                                                                     "*prop": "proxy",
1460                                                                     "method": "GET",
1461                                                                     "xtype": "HttpProxy",
1462                                                                     "|url": "baseURL + '/Roo/shiptoinfo.php'",
1463                                                                     "|xns": "Roo.data"
1464                                                                 },
1465                                                                 {
1466                                                                     "*prop": "reader",
1467                                                                     "id": "shipto_id",
1468                                                                     "root": "data",
1469                                                                     "totalProperty": "total",
1470                                                                     "xtype": "JsonReader",
1471                                                                     "|fields": "[{\"name\":\"cntct_id\",\"type\":\"int\"},\"cntct_name\"]",
1472                                                                     "|xns": "Roo.data"
1473                                                                 }
1474                                                             ]
1475                                                         }
1476                                                     ]
1477                                                 }
1478                                             ]
1479                                         }
1480                                     ]
1481                                 },
1482                                 {
1483                                     "*prop": "colModel[]",
1484                                     ".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\":\"\"}",
1485                                     "dataIndex": "item_descrip1",
1486                                     "header": "Item Description",
1487                                     "width": "150.00",
1488                                     "xtype": "ColumnModel",
1489                                     "|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}",
1490                                     "|xns": "Roo.grid",
1491                                     "items": [
1492                                         {
1493                                             "|xns": "Roo.grid",
1494                                             "xtype": "GridEditor",
1495                                             "*prop": "editor",
1496                                             "items": [
1497                                                 {
1498                                                     "*prop": "field",
1499                                                     "allowBlank": false,
1500                                                     "xtype": "TextField",
1501                                                     "|xns": "Roo.form"
1502                                                 }
1503                                             ]
1504                                         }
1505                                     ]
1506                                 },
1507                                 {
1508                                     "*prop": "colModel[]",
1509                                     ".builderCfg": "{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}",
1510                                     "align": "right",
1511                                     "dataIndex": "coitem_status",
1512                                     "header": "Status",
1513                                     "width": 50,
1514                                     "xtype": "ColumnModel",
1515                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1516                                     "|xns": "Roo.grid"
1517                                 },
1518                                 {
1519                                     "*prop": "colModel[]",
1520                                     "align": "right",
1521                                     "dataIndex": "coitem_qtyord",
1522                                     "header": "Qty",
1523                                     "width": 40,
1524                                     "xtype": "ColumnModel",
1525                                     "|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}",
1526                                     "|xns": "Roo.grid",
1527                                     "items": [
1528                                         {
1529                                             "*prop": "editor",
1530                                             "xtype": "GridEditor",
1531                                             "|xns": "Roo.grid",
1532                                             "items": [
1533                                                 {
1534                                                     "listeners": {
1535                                                         "focus": "function (_self)\n{\n    if (this.value == 0) {\n        this.el.dom.value = '';\n    }\n}"
1536                                                     },
1537                                                     "*prop": "field",
1538                                                     "allowDecimals": false,
1539                                                     "decimalPrecision": 0,
1540                                                     "minValue": 1,
1541                                                     "style": "text-align:right",
1542                                                     "xtype": "NumberField",
1543                                                     "|xns": "Roo.form"
1544                                                 }
1545                                             ]
1546                                         }
1547                                     ]
1548                                 },
1549                                 {
1550                                     "*prop": "colModel[]",
1551                                     "align": "right",
1552                                     "dataIndex": "coitem_price",
1553                                     "header": "Sell @",
1554                                     "width": 70,
1555                                     "xtype": "ColumnModel",
1556                                     "|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}",
1557                                     "|xns": "Roo.grid",
1558                                     "items": [
1559                                         {
1560                                             "|xns": "Roo.grid",
1561                                             "xtype": "GridEditor",
1562                                             "*prop": "editor",
1563                                             "items": [
1564                                                 {
1565                                                     "listeners": {
1566                                                         "focus": "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1567                                                     },
1568                                                     "*prop": "field",
1569                                                     "decimalPrecision": 3,
1570                                                     "minValue": 0,
1571                                                     "style": "text-align:right",
1572                                                     "xtype": "NumberField",
1573                                                     "|xns": "Roo.form"
1574                                                 }
1575                                             ]
1576                                         }
1577                                     ]
1578                                 },
1579                                 {
1580                                     "*prop": "colModel[]",
1581                                     "align": "right",
1582                                     "dataIndex": "coitem_price_tax",
1583                                     "header": "Sell @w/GST",
1584                                     "hidden": true,
1585                                     "width": 70,
1586                                     "xtype": "ColumnModel",
1587                                     "|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}",
1588                                     "|xns": "Roo.grid",
1589                                     "items": [
1590                                         {
1591                                             "|xns": "Roo.grid",
1592                                             "xtype": "GridEditor",
1593                                             "*prop": "editor",
1594                                             "items": [
1595                                                 {
1596                                                     "listeners": {
1597                                                         "focus": "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1598                                                     },
1599                                                     "*prop": "field",
1600                                                     "decimalPrecision": 3,
1601                                                     "minValue": 0,
1602                                                     "style": "text-align:right",
1603                                                     "xtype": "NumberField",
1604                                                     "|xns": "Roo.form"
1605                                                 }
1606                                             ]
1607                                         }
1608                                     ]
1609                                 },
1610                                 {
1611                                     "*prop": "colModel[]",
1612                                     "align": "right",
1613                                     "dataIndex": "coitem_linedisc",
1614                                     "header": "Disc%",
1615                                     "width": 50,
1616                                     "xtype": "ColumnModel",
1617                                     "|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}",
1618                                     "|xns": "Roo.grid",
1619                                     "items": [
1620                                         {
1621                                             "|xns": "Roo.grid",
1622                                             "xtype": "GridEditor",
1623                                             "*prop": "editor",
1624                                             "items": [
1625                                                 {
1626                                                     "listeners": {
1627                                                         "focus": "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1628                                                     },
1629                                                     "*prop": "field",
1630                                                     "decimalPrecision": 2,
1631                                                     "maxValue": 100,
1632                                                     "minValue": 0,
1633                                                     "style": "text-align:right",
1634                                                     "xtype": "NumberField",
1635                                                     "|xns": "Roo.form"
1636                                                 }
1637                                             ]
1638                                         }
1639                                     ]
1640                                 },
1641                                 {
1642                                     "*prop": "colModel[]",
1643                                     "align": "right",
1644                                     "dataIndex": "coitem_custprice",
1645                                     "header": "List Price",
1646                                     "width": 70,
1647                                     "xtype": "ColumnModel",
1648                                     "|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}",
1649                                     "|xns": "Roo.grid",
1650                                     "items": [
1651                                         {
1652                                             "|xns": "Roo.grid",
1653                                             "xtype": "GridEditor",
1654                                             "*prop": "editor",
1655                                             "items": [
1656                                                 {
1657                                                     "listeners": {
1658                                                         "focus": "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1659                                                     },
1660                                                     "*prop": "field",
1661                                                     "decimalPrecision": 3,
1662                                                     "minValue": 0,
1663                                                     "style": "text-align:right",
1664                                                     "xtype": "NumberField",
1665                                                     "|xns": "Roo.form"
1666                                                 }
1667                                             ]
1668                                         }
1669                                     ]
1670                                 },
1671                                 {
1672                                     "*prop": "colModel[]",
1673                                     "align": "right",
1674                                     "dataIndex": "coitem_custprice_tax",
1675                                     "header": "List Price w/GST",
1676                                     "hidden": true,
1677                                     "width": 70,
1678                                     "xtype": "ColumnModel",
1679                                     "|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}",
1680                                     "|xns": "Roo.grid",
1681                                     "items": [
1682                                         {
1683                                             "|xns": "Roo.grid",
1684                                             "xtype": "GridEditor",
1685                                             "*prop": "editor",
1686                                             "items": [
1687                                                 {
1688                                                     "listeners": {
1689                                                         "focus": "function (_self)\n{\n    if (this.value == 0.0) {\n        this.el.dom.value = '';\n    }\n}"
1690                                                     },
1691                                                     "*prop": "field",
1692                                                     "decimalPrecision": 3,
1693                                                     "minValue": 0,
1694                                                     "style": "text-align:right",
1695                                                     "xtype": "NumberField",
1696                                                     "|xns": "Roo.form"
1697                                                 }
1698                                             ]
1699                                         }
1700                                     ]
1701                                 },
1702                                 {
1703                                     "*prop": "colModel[]",
1704                                     "align": "right",
1705                                     "dataIndex": "coitem_subtotal",
1706                                     "header": "SubTotal",
1707                                     "width": 70,
1708                                     "xtype": "ColumnModel",
1709                                     "|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  }",
1710                                     "|xns": "Roo.grid"
1711                                 },
1712                                 {
1713                                     "*prop": "colModel[]",
1714                                     "align": "right",
1715                                     "dataIndex": "coitem_subtotal_tax",
1716                                     "header": "SubTotal w/GST",
1717                                     "hidden": true,
1718                                     "width": 70,
1719                                     "xtype": "ColumnModel",
1720                                     "|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}",
1721                                     "|xns": "Roo.grid"
1722                                 },
1723                                 {
1724                                     "*prop": "colModel[]",
1725                                     ".builderCfg": "{\"table\":\"coitem\",\"column\":\"coitem_unitcost\",\"columnshort\":\"coitem_unitcost\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"Unit Cost\"}",
1726                                     "align": "right",
1727                                     "dataIndex": "coitem_unitcost_in_order_cur",
1728                                     "header": "Unit Cost",
1729                                     "width": 50,
1730                                     "xtype": "ColumnModel",
1731                                     "|renderer": "function(v) { return Roo.util.Format.number( v, 2); }",
1732                                     "|xns": "Roo.grid"
1733                                 },
1734                                 {
1735                                     "*prop": "colModel[]",
1736                                     "align": "right",
1737                                     "dataIndex": "coitem_taxtype_id",
1738                                     "header": "Taxed",
1739                                     "width": 50,
1740                                     "xtype": "ColumnModel",
1741                                     "|renderer": "function(v,x,r) { return String.format('{0}', r.data.coitem_taxtype_id_taxtype_name); }",
1742                                     "|xns": "Roo.grid",
1743                                     "items": [
1744                                         {
1745                                             "|xns": "Roo.grid",
1746                                             "xtype": "GridEditor",
1747                                             "*prop": "editor",
1748                                             "items": [
1749                                                 {
1750                                                     "*prop": "field",
1751                                                     "allowBlank": false,
1752                                                     "displayField": "taxtype_name",
1753                                                     "editable": false,
1754                                                     "emptyText": "Select Tax Type",
1755                                                     "forceSelection": true,
1756                                                     "hiddenName": "coitem_taxtype_id",
1757                                                     "listWidth": 400,
1758                                                     "loadingText": "Searching...",
1759                                                     "minChars": 2,
1760                                                     "name": "coitem_taxtype_id_taxtype_name",
1761                                                     "pageSize": 20,
1762                                                     "qtip": "Select taxtype",
1763                                                     "queryParam": "query[taxtype_id]",
1764                                                     "selectOnFocus": true,
1765                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{taxtype_name}</b> </div>",
1766                                                     "triggerAction": "all",
1767                                                     "typeAhead": true,
1768                                                     "valueField": "taxtype_id",
1769                                                     "width": 40,
1770                                                     "xtype": "ComboBox",
1771                                                     "|xns": "Roo.form",
1772                                                     "items": [
1773                                                         {
1774                                                             "listeners": {
1775                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    \n    \n}\n"
1776                                                             },
1777                                                             "*prop": "store",
1778                                                             "remoteSort": true,
1779                                                             "xtype": "Store",
1780                                                             "|sortInfo": "{ direction : 'ASC', field: 'taxtype_name' }",
1781                                                             "|xns": "Roo.data",
1782                                                             "items": [
1783                                                                 {
1784                                                                     "*prop": "proxy",
1785                                                                     "method": "GET",
1786                                                                     "xtype": "HttpProxy",
1787                                                                     "|url": "baseURL + '/Roo/taxtype.php'",
1788                                                                     "|xns": "Roo.data"
1789                                                                 },
1790                                                                 {
1791                                                                     "*prop": "reader",
1792                                                                     "id": "taxtype_id",
1793                                                                     "root": "data",
1794                                                                     "totalProperty": "total",
1795                                                                     "xtype": "JsonReader",
1796                                                                     "|fields": "[{\"name\":\"taxtype_id\",\"type\":\"int\"},\"taxtype_name\"]",
1797                                                                     "|xns": "Roo.data"
1798                                                                 }
1799                                                             ]
1800                                                         }
1801                                                     ]
1802                                                 }
1803                                             ]
1804                                         }
1805                                     ]
1806                                 },
1807                                 {
1808                                     "*prop": "colModel[]",
1809                                     "align": "right",
1810                                     "dataIndex": "avail_qty",
1811                                     "header": "#avail",
1812                                     "width": 50,
1813                                     "xtype": "ColumnModel",
1814                                     "|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}",
1815                                     "|xns": "Roo.grid"
1816                                 },
1817                                 {
1818                                     "*prop": "colModel[]",
1819                                     ".builderCfg": "{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}",
1820                                     "align": "right",
1821                                     "dataIndex": "shipitem_shipped",
1822                                     "header": "#reserved",
1823                                     "width": 50,
1824                                     "xtype": "ColumnModel",
1825                                     "|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}",
1826                                     "|xns": "Roo.grid"
1827                                 },
1828                                 {
1829                                     "*prop": "colModel[]",
1830                                     ".builderCfg": "{\"table\":\"coitem\",\"column\":\"coitem_qtyreserved\",\"columnshort\":\"coitem_qtyreserved\",\"ctype\":\"numeric\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"#reserved\"}",
1831                                     "align": "right",
1832                                     "dataIndex": "coitem_qtyshipped",
1833                                     "header": "#shipped",
1834                                     "width": 50,
1835                                     "xtype": "ColumnModel",
1836                                     "|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}",
1837                                     "|xns": "Roo.grid"
1838                                 },
1839                                 {
1840                                     "*prop": "colModel[]",
1841                                     "align": "right",
1842                                     "dataIndex": "cobill_billed",
1843                                     "header": "#invoiced",
1844                                     "width": 50,
1845                                     "xtype": "ColumnModel",
1846                                     "|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}",
1847                                     "|xns": "Roo.grid"
1848                                 }
1849                             ]
1850                         }
1851                     ]
1852                 },
1853                 {
1854                     "listeners": {
1855                         "activate": "function (_self)\n{\n    _this.shipinvtab = _self;\n}"
1856                     },
1857                     "region": "center",
1858                     "title": "Shipments / Invoices",
1859                     "xtype": "NestedLayoutPanel",
1860                     "|xns": "Roo",
1861                     "items": [
1862                         {
1863                             "|xns": "Roo",
1864                             "xtype": "BorderLayout",
1865                             "*prop": "layout",
1866                             "items": [
1867                                 {
1868                                     "*prop": "center",
1869                                     "titlebar": true,
1870                                     "xtype": "LayoutRegion",
1871                                     "|xns": "Roo"
1872                                 },
1873                                 {
1874                                     "*prop": "north",
1875                                     "height": 250,
1876                                     "title": "Reserve Stock / Shipments",
1877                                     "xtype": "LayoutRegion",
1878                                     "|xns": "Roo"
1879                                 },
1880                                 {
1881                                     "listeners": {
1882                                         "|activate": "function() {\n    _this.shippanel = this;\n    if (_this.shipgrid) {\n        _this.shipgrid.ds.load({});\n    }\n}"
1883                                     },
1884                                     ".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\"}",
1885                                     "background": false,
1886                                     "fitContainer": true,
1887                                     "fitToframe": true,
1888                                     "region": "north",
1889                                     "tableName": "shiphead",
1890                                     "title": "shiphead",
1891                                     "xtype": "GridPanel",
1892                                     "|xns": "Roo",
1893                                     "items": [
1894                                         {
1895                                             "listeners": {
1896                                                 "|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}",
1897                                                 "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"
1898                                             },
1899                                             "*prop": "grid",
1900                                             ".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\"}",
1901                                             "autoExpandColumn": "shiphead_shipvia",
1902                                             "loadMask": true,
1903                                             "xtype": "Grid",
1904                                             "|xns": "Roo.grid",
1905                                             "items": [
1906                                                 {
1907                                                     "*prop": "sm",
1908                                                     "singleSelect": true,
1909                                                     "xtype": "RowSelectionModel",
1910                                                     "|xns": "Roo.grid"
1911                                                 },
1912                                                 {
1913                                                     "listeners": {
1914                                                         "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}"
1915                                                     },
1916                                                     "*prop": "dataSource",
1917                                                     ".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\"}",
1918                                                     "remoteSort": true,
1919                                                     "xtype": "Store",
1920                                                     "|sortInfo": "{ field : 'shiphead_shipvia', direction: 'ASC' }",
1921                                                     "|xns": "Roo.data",
1922                                                     "items": [
1923                                                         {
1924                                                             "*prop": "proxy",
1925                                                             "xtype": "HttpProxy",
1926                                                             "method": "GET",
1927                                                             "|url": "baseURL + '/Roo/shiphead.php'",
1928                                                             "|xns": "Roo.data"
1929                                                         },
1930                                                         {
1931                                                             "|xns": "Roo.data",
1932                                                             "xtype": "JsonReader",
1933                                                             "totalProperty": "total",
1934                                                             "root": "data",
1935                                                             ".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\"}",
1936                                                             "*prop": "reader",
1937                                                             "id": "id",
1938                                                             "|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]"
1939                                                         }
1940                                                     ]
1941                                                 },
1942                                                 {
1943                                                     "*prop": "toolbar",
1944                                                     "xtype": "Toolbar",
1945                                                     "|xns": "Roo",
1946                                                     "items": [
1947                                                         {
1948                                                             "listeners": {
1949                                                                 "|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}"
1950                                                             },
1951                                                             "cls": "x-btn-text-icon",
1952                                                             "text": "Confirm Shipment",
1953                                                             "xtype": "Button",
1954                                                             "|icon": "rootURL + '/Pman/templates/images/lock.gif'",
1955                                                             "|xns": "Roo.Toolbar"
1956                                                         },
1957                                                         {
1958                                                             "listeners": {
1959                                                                 "|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}"
1960                                                             },
1961                                                             "cls": "x-btn-text-icon",
1962                                                             "text": "Download (as xls)",
1963                                                             "xtype": "Button",
1964                                                             "|icon": "rootURL + '/Pman/templates/images/save.gif'",
1965                                                             "|xns": "Roo.Toolbar"
1966                                                         },
1967                                                         {
1968                                                             "listeners": {
1969                                                                 "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}"
1970                                                             },
1971                                                             "cls": "x-btn-text-icon",
1972                                                             "text": "Print Picking Slip",
1973                                                             "xtype": "Button",
1974                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
1975                                                             "|xns": "Roo.Toolbar"
1976                                                         },
1977                                                         {
1978                                                             "listeners": {
1979                                                                 "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}"
1980                                                             },
1981                                                             "cls": "x-btn-text-icon",
1982                                                             "text": "Print Delivery Note",
1983                                                             "xtype": "Button",
1984                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
1985                                                             "|xns": "Roo.Toolbar"
1986                                                         },
1987                                                         {
1988                                                             "listeners": {
1989                                                                 "|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    if(!s.data.shiphead_shipdate.length || !s.data.shiphead_delivery_note.length || !s.data.shiphead_shipped){\n        Roo.MessageBox.alert('Error', 'Shipment has not been confirmed or the delivery note has not been filled!');\n        return;\n    }\n    \n    Roo.log(s);\n}\n"
1990                                                             },
1991                                                             "cls": "x-btn-text-icon",
1992                                                             "text": "Send Delivery Email",
1993                                                             "xtype": "Button",
1994                                                             "|icon": "Roo.rootURL + 'images/default/dd/email.gif'",
1995                                                             "|xns": "Roo.Toolbar"
1996                                                         },
1997                                                         {
1998                                                             "xtype": "Fill",
1999                                                             "|xns": "Roo.Toolbar"
2000                                                         },
2001                                                         {
2002                                                             "listeners": {
2003                                                                 "|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}",
2004                                                                 "render": "function (_self)\n{\n  _this.addShipmentBtn = _self;\n}"
2005                                                             },
2006                                                             "cls": "x-btn-text-icon",
2007                                                             "text": "Add",
2008                                                             "xtype": "Button",
2009                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2010                                                             "|xns": "Roo.Toolbar"
2011                                                         },
2012                                                         {
2013                                                             "listeners": {
2014                                                                 "|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        "
2015                                                             },
2016                                                             "cls": "x-btn-text-icon",
2017                                                             "text": "Void / Unconfirm",
2018                                                             "xtype": "Button",
2019                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2020                                                             "|xns": "Roo.Toolbar"
2021                                                         }
2022                                                     ]
2023                                                 },
2024                                                 {
2025                                                     "*prop": "colModel[]",
2026                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2027                                                     "dataIndex": "shiphead_number",
2028                                                     "header": "number",
2029                                                     "width": 80,
2030                                                     "xtype": "ColumnModel",
2031                                                     "|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 }",
2032                                                     "|xns": "Roo.grid"
2033                                                 },
2034                                                 {
2035                                                     "*prop": "colModel[]",
2036                                                     "dataIndex": "shiphead_location_id_location_name",
2037                                                     "header": "From Location",
2038                                                     "width": 100,
2039                                                     "xtype": "ColumnModel",
2040                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2041                                                     "|xns": "Roo.grid"
2042                                                 },
2043                                                 {
2044                                                     "*prop": "colModel[]",
2045                                                     "dataIndex": "shiphead_shipto_id_shipto_name",
2046                                                     "header": "Ship to",
2047                                                     "width": 100,
2048                                                     "xtype": "ColumnModel",
2049                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2050                                                     "|xns": "Roo.grid"
2051                                                 },
2052                                                 {
2053                                                     "xtype": "ColumnModel",
2054                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2055                                                     "header": "shipdate",
2056                                                     "width": 75,
2057                                                     "dataIndex": "shiphead_shipdate",
2058                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
2059                                                     "|xns": "Roo.grid",
2060                                                     "*prop": "colModel[]"
2061                                                 },
2062                                                 {
2063                                                     "*prop": "colModel[]",
2064                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2065                                                     "dataIndex": "shiphead_sfstatus",
2066                                                     "header": "Status",
2067                                                     "width": 50,
2068                                                     "xtype": "ColumnModel",
2069                                                     "|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}",
2070                                                     "|xns": "Roo.grid"
2071                                                 },
2072                                                 {
2073                                                     "xtype": "ColumnModel",
2074                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}",
2075                                                     "header": "shipvia",
2076                                                     "width": 200,
2077                                                     "dataIndex": "shiphead_shipvia",
2078                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2079                                                     "|xns": "Roo.grid",
2080                                                     "*prop": "colModel[]"
2081                                                 },
2082                                                 {
2083                                                     "xtype": "ColumnModel",
2084                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2085                                                     "header": "tracknum",
2086                                                     "width": 200,
2087                                                     "dataIndex": "shiphead_tracknum",
2088                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2089                                                     "|xns": "Roo.grid",
2090                                                     "*prop": "colModel[]"
2091                                                 }
2092                                             ]
2093                                         }
2094                                     ]
2095                                 },
2096                                 {
2097                                     "listeners": {
2098                                         "|activate": "function() {\n    _this.invpanel = this;\n    if (_this.invgrid) {\n        _this.invgrid.ds.load({});\n    }\n}"
2099                                     },
2100                                     "background": false,
2101                                     "fitContainer": true,
2102                                     "fitToframe": true,
2103                                     "region": "center",
2104                                     "tableName": "cobmisc",
2105                                     "title": "Invoices",
2106                                     "xtype": "GridPanel",
2107                                     "|xns": "Roo",
2108                                     "items": [
2109                                         {
2110                                             "listeners": {
2111                                                 "|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}",
2112                                                 "|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"
2113                                             },
2114                                             "*prop": "grid",
2115                                             ".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\"}",
2116                                             "autoExpandColumn": "invchead_invcnumber",
2117                                             "loadMask": true,
2118                                             "xtype": "Grid",
2119                                             "|xns": "Roo.grid",
2120                                             "items": [
2121                                                 {
2122                                                     "listeners": {
2123                                                         "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}",
2124                                                         "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}"
2125                                                     },
2126                                                     "*prop": "dataSource",
2127                                                     "remoteSort": true,
2128                                                     "xtype": "Store",
2129                                                     "|sortInfo": "{ field : 'invchead_invcnumber', direction: 'ASC' }",
2130                                                     "|xns": "Roo.data",
2131                                                     "items": [
2132                                                         {
2133                                                             "*prop": "proxy",
2134                                                             "method": "GET",
2135                                                             "xtype": "HttpProxy",
2136                                                             "|url": "baseURL + '/Roo/cobmisc.php'",
2137                                                             "|xns": "Roo.data"
2138                                                         },
2139                                                         {
2140                                                             "*prop": "reader",
2141                                                             ".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\"}",
2142                                                             "id": "id",
2143                                                             "root": "data",
2144                                                             "totalProperty": "total",
2145                                                             "xtype": "JsonReader",
2146                                                             "|fields": "[\n    {\n        'name': 'invchead_invcnumber',\n        'type': 'string'\n    },\n    {\n        'name': 'invchead_invcdate',\n        'type': 'date'\n    }\n]",
2147                                                             "|xns": "Roo.data"
2148                                                         }
2149                                                     ]
2150                                                 },
2151                                                 {
2152                                                     "*prop": "toolbar",
2153                                                     "xtype": "Toolbar",
2154                                                     "|xns": "Roo",
2155                                                     "items": [
2156                                                         {
2157                                                             "listeners": {
2158                                                                 "|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}"
2159                                                             },
2160                                                             "cls": "x-btn-text-icon",
2161                                                             "text": "Post Invoice",
2162                                                             "xtype": "Button",
2163                                                             "|icon": "rootURL + '/Pman/templates/images/lock.gif'",
2164                                                             "|xns": "Roo.Toolbar"
2165                                                         },
2166                                                         {
2167                                                             "cls": "x-btn-text-icon",
2168                                                             "text": "Print",
2169                                                             "xtype": "Button",
2170                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
2171                                                             "|xns": "Roo.Toolbar",
2172                                                             "items": [
2173                                                                 {
2174                                                                     "|xns": "Roo.menu",
2175                                                                     "xtype": "Menu",
2176                                                                     "*prop": "menu",
2177                                                                     "items": [
2178                                                                         {
2179                                                                             "listeners": {
2180                                                                                 "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}"
2181                                                                             },
2182                                                                             "text": "Print Standard Invoice",
2183                                                                             "xtype": "Item",
2184                                                                             "|xns": "Roo.menu"
2185                                                                         },
2186                                                                         {
2187                                                                             "listeners": {
2188                                                                                 "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} "
2189                                                                             },
2190                                                                             "text": "Print Chinese Invoice With GST in line item",
2191                                                                             "xtype": "Item",
2192                                                                             "|hidden": "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2193                                                                             "|xns": "Roo.menu"
2194                                                                         },
2195                                                                         {
2196                                                                             "listeners": {
2197                                                                                 "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} "
2198                                                                             },
2199                                                                             "text": "Print Chinese Invoice",
2200                                                                             "xtype": "Item",
2201                                                                             "|hidden": "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2202                                                                             "|xns": "Roo.menu"
2203                                                                         },
2204                                                                         {
2205                                                                             "listeners": {
2206                                                                                 "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} "
2207                                                                             },
2208                                                                             "text": "Print Aus - GST included Invoice",
2209                                                                             "xtype": "Item",
2210                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2211                                                                             "|xns": "Roo.menu"
2212                                                                         },
2213                                                                         {
2214                                                                             "listeners": {
2215                                                                                 "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}"
2216                                                                             },
2217                                                                             "text": "Print Bambini Pronto Invoice",
2218                                                                             "xtype": "Item",
2219                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2220                                                                             "|xns": "Roo.menu"
2221                                                                         },
2222                                                                         {
2223                                                                             "listeners": {
2224                                                                                 "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} "
2225                                                                             },
2226                                                                             "text": "Print Bambini Pro Forma Invoice",
2227                                                                             "xtype": "Item",
2228                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2229                                                                             "|xns": "Roo.menu"
2230                                                                         },
2231                                                                         {
2232                                                                             "listeners": {
2233                                                                                 "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}"
2234                                                                             },
2235                                                                             "text": "Print Shipping / Commercial Invoice",
2236                                                                             "xtype": "Item",
2237                                                                             "|hidden": "!( baseURL.match(/au\\.php$/)) ",
2238                                                                             "|xns": "Roo.menu"
2239                                                                         }
2240                                                                     ]
2241                                                                 }
2242                                                             ]
2243                                                         },
2244                                                         {
2245                                                             "cls": "x-btn-text-icon",
2246                                                             "text": "Payments / Refunds / Credit Memos",
2247                                                             "xtype": "Button",
2248                                                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
2249                                                             "|xns": "Roo.Toolbar",
2250                                                             "items": [
2251                                                                 {
2252                                                                     "|xns": "Roo.menu",
2253                                                                     "xtype": "Menu",
2254                                                                     "*prop": "menu",
2255                                                                     "items": [
2256                                                                         {
2257                                                                             "listeners": {
2258                                                                                 "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"
2259                                                                             },
2260                                                                             "cls": "x-btn-text-icon",
2261                                                                             "text": "Receive Payment",
2262                                                                             "xtype": "Item",
2263                                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2264                                                                             "|xns": "Roo.menu"
2265                                                                         },
2266                                                                         {
2267                                                                             "listeners": {
2268                                                                                 "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"
2269                                                                             },
2270                                                                             "cls": "x-btn-text-icon",
2271                                                                             "text": "Issue Refund",
2272                                                                             "xtype": "Item",
2273                                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2274                                                                             "|xns": "Roo.menu"
2275                                                                         },
2276                                                                         {
2277                                                                             "|xns": "Roo.menu",
2278                                                                             "xtype": "Separator"
2279                                                                         },
2280                                                                         {
2281                                                                             "listeners": {
2282                                                                                 "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"
2283                                                                             },
2284                                                                             "cls": "x-btn-text-icon",
2285                                                                             "text": "Void Payment",
2286                                                                             "xtype": "Item",
2287                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2288                                                                             "|xns": "Roo.menu"
2289                                                                         },
2290                                                                         {
2291                                                                             "listeners": {
2292                                                                                 "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"
2293                                                                             },
2294                                                                             "cls": "x-btn-text-icon",
2295                                                                             "text": "Void Refund",
2296                                                                             "xtype": "Item",
2297                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2298                                                                             "|xns": "Roo.menu"
2299                                                                         },
2300                                                                         {
2301                                                                             "listeners": {
2302                                                                                 "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"
2303                                                                             },
2304                                                                             "cls": "x-btn-text-icon",
2305                                                                             "text": "Void Credit Memo",
2306                                                                             "xtype": "Item",
2307                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2308                                                                             "|xns": "Roo.menu"
2309                                                                         }
2310                                                                     ]
2311                                                                 }
2312                                                             ]
2313                                                         },
2314                                                         {
2315                                                             "xtype": "Fill",
2316                                                             "|xns": "Roo.Toolbar"
2317                                                         },
2318                                                         {
2319                                                             "listeners": {
2320                                                                 "|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}",
2321                                                                 "render": "function (_self)\n{\n  _this.addInvoiceBtn = _self;\n}"
2322                                                             },
2323                                                             "cls": "x-btn-text-icon",
2324                                                             "text": "Add",
2325                                                             "xtype": "Button",
2326                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2327                                                             "|xns": "Roo.Toolbar"
2328                                                         },
2329                                                         {
2330                                                             "listeners": {
2331                                                                 "|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}"
2332                                                             },
2333                                                             "cls": "x-btn-text-icon",
2334                                                             "text": "Void / Unpost",
2335                                                             "xtype": "Button",
2336                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2337                                                             "|xns": "Roo.Toolbar"
2338                                                         }
2339                                                     ]
2340                                                 },
2341                                                 {
2342                                                     "*prop": "colModel[]",
2343                                                     "dataIndex": "cobmisc_invchead_id_invchead_invcnumber",
2344                                                     "header": "Invoice #",
2345                                                     "width": 100,
2346                                                     "xtype": "ColumnModel",
2347                                                     "|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) [ {1} ]</span>', v, r.data.cobmisc_cashrcpt_amount); \n       }\n       \n        return v ? String.format('{0}', v) : \n                '<span style=\"color:red\">' + \"Not Posted\" + '</span>'; \n}",
2348                                                     "|xns": "Roo.grid"
2349                                                 },
2350                                                 {
2351                                                     "*prop": "colModel[]",
2352                                                     ".builderCfg": "{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2353                                                     "dataIndex": "cobmisc_invcdate",
2354                                                     "header": "invcdate",
2355                                                     "width": 75,
2356                                                     "xtype": "ColumnModel",
2357                                                     "|renderer": "function(v,x,r) { \n\n        return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : ''); \n}",
2358                                                     "|xns": "Roo.grid"
2359                                                 },
2360                                                 {
2361                                                     "*prop": "colModel[]",
2362                                                     "align": "right",
2363                                                     "dataIndex": "cobmisc_qty",
2364                                                     "header": "Qty",
2365                                                     "width": 50,
2366                                                     "xtype": "ColumnModel",
2367                                                     "|renderer": "function(v) { return String.format('{0}', v ? parseInt(v) : 0); }",
2368                                                     "|xns": "Roo.grid"
2369                                                 },
2370                                                 {
2371                                                     "*prop": "colModel[]",
2372                                                     "align": "right",
2373                                                     "dataIndex": "cobmisc_itemcost",
2374                                                     "header": "Item Cost",
2375                                                     "width": 75,
2376                                                     "xtype": "ColumnModel",
2377                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : 0); }",
2378                                                     "|xns": "Roo.grid"
2379                                                 },
2380                                                 {
2381                                                     "*prop": "colModel[]",
2382                                                     "align": "right",
2383                                                     "dataIndex": "cobmisc_freight",
2384                                                     "header": "Shipping",
2385                                                     "width": 75,
2386                                                     "xtype": "ColumnModel",
2387                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : ''); }",
2388                                                     "|xns": "Roo.grid"
2389                                                 },
2390                                                 {
2391                                                     "*prop": "colModel[]",
2392                                                     "align": "right",
2393                                                     "dataIndex": "cobmisc_tax",
2394                                                     "header": "Tax",
2395                                                     "width": 75,
2396                                                     "xtype": "ColumnModel",
2397                                                     "|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 }",
2398                                                     "|xns": "Roo.grid"
2399                                                 },
2400                                                 {
2401                                                     "*prop": "colModel[]",
2402                                                     "align": "right",
2403                                                     "dataIndex": "cobmisc_cohead_id_cohead_pretax_discount",
2404                                                     "header": "Discount (Pretax)",
2405                                                     "width": 100,
2406                                                     "xtype": "ColumnModel",
2407                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }",
2408                                                     "|xns": "Roo.grid"
2409                                                 },
2410                                                 {
2411                                                     "*prop": "colModel[]",
2412                                                     "align": "right",
2413                                                     "dataIndex": "cobmisc_misc",
2414                                                     "header": "Discount (Posttax)",
2415                                                     "width": 100,
2416                                                     "xtype": "ColumnModel",
2417                                                     "|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}",
2418                                                     "|xns": "Roo.grid"
2419                                                 },
2420                                                 {
2421                                                     "*prop": "colModel[]",
2422                                                     "align": "right",
2423                                                     "dataIndex": "cobmisc_total",
2424                                                     "header": "Total ",
2425                                                     "width": 75,
2426                                                     "xtype": "ColumnModel",
2427                                                     "|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}",
2428                                                     "|xns": "Roo.grid"
2429                                                 },
2430                                                 {
2431                                                     "*prop": "colModel[]",
2432                                                     "align": "right",
2433                                                     "dataIndex": "cobmisc_outstanding",
2434                                                     "header": "Outstanding",
2435                                                     "width": 75,
2436                                                     "xtype": "ColumnModel",
2437                                                     "|renderer": "function(v,x,r) \n{ \n    \n    return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );\n}",
2438                                                     "|xns": "Roo.grid"
2439                                                 }
2440                                             ]
2441                                         }
2442                                     ]
2443                                 }
2444                             ]
2445                         }
2446                     ]
2447                 },
2448                 {
2449                     "listeners": {
2450                         "|activate": "function() {\n    _this.hpanel = this;\n    if (_this.hgrid) {\n        _this.hgrid.footer.onClick('first');\n    }\n}"
2451                     },
2452                     ".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\"}",
2453                     "background": true,
2454                     "fitContainer": true,
2455                     "fitToframe": true,
2456                     "region": "center",
2457                     "tableName": "events",
2458                     "title": "History",
2459                     "xtype": "GridPanel",
2460                     "|xns": "Roo",
2461                     "items": [
2462                         {
2463                             "listeners": {
2464                                 "|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}",
2465                                 "|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"
2466                             },
2467                             "*prop": "grid",
2468                             ".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\"}",
2469                             "autoExpandColumn": "remarks",
2470                             "loadMask": true,
2471                             "xtype": "Grid",
2472                             "|xns": "Roo.grid",
2473                             "items": [
2474                                 {
2475                                     "listeners": {
2476                                         "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}"
2477                                     },
2478                                     "*prop": "dataSource",
2479                                     ".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\"}",
2480                                     "remoteSort": true,
2481                                     "xtype": "Store",
2482                                     "|sortInfo": "{ field : 'event_when', direction: 'DESC' }",
2483                                     "|xns": "Roo.data",
2484                                     "items": [
2485                                         {
2486                                             "*prop": "proxy",
2487                                             "xtype": "HttpProxy",
2488                                             "method": "GET",
2489                                             "|url": "baseURL + '/Roo/events.php'",
2490                                             "|xns": "Roo.data"
2491                                         },
2492                                         {
2493                                             "*prop": "reader",
2494                                             ".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\"}",
2495                                             "id": "id",
2496                                             "root": "data",
2497                                             "totalProperty": "total",
2498                                             "xtype": "JsonReader",
2499                                             "|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]",
2500                                             "|xns": "Roo.data"
2501                                         }
2502                                     ]
2503                                 },
2504                                 {
2505                                     "*prop": "footer",
2506                                     "xtype": "PagingToolbar",
2507                                     "pageSize": 25,
2508                                     "displayInfo": true,
2509                                     "displayMsg": "Displaying events{0} - {1} of {2}",
2510                                     "emptyMsg": "No events found",
2511                                     "|xns": "Roo"
2512                                 },
2513                                 {
2514                                     "*prop": "colModel[]",
2515                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2516                                     "dataIndex": "event_when",
2517                                     "header": "Changed",
2518                                     "width": 120,
2519                                     "xtype": "ColumnModel",
2520                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }",
2521                                     "|xns": "Roo.grid"
2522                                 },
2523                                 {
2524                                     "*prop": "colModel[]",
2525                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2526                                     "dataIndex": "action",
2527                                     "header": "action",
2528                                     "width": 120,
2529                                     "xtype": "ColumnModel",
2530                                     "|renderer": "function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }",
2531                                     "|xns": "Roo.grid"
2532                                 },
2533                                 {
2534                                     "*prop": "colModel[]",
2535                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2536                                     "dataIndex": "ipaddr",
2537                                     "header": "IP address",
2538                                     "width": 120,
2539                                     "xtype": "ColumnModel",
2540                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2541                                     "|xns": "Roo.grid"
2542                                 },
2543                                 {
2544                                     "*prop": "colModel[]",
2545                                     ".builderCfg": "{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2546                                     "dataIndex": "person_id_name",
2547                                     "header": "Who",
2548                                     "width": 120,
2549                                     "xtype": "ColumnModel",
2550                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2551                                     "|xns": "Roo.grid"
2552                                 },
2553                                 {
2554                                     "*prop": "colModel[]",
2555                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}",
2556                                     "dataIndex": "remarks",
2557                                     "header": "Notes",
2558                                     "width": 200,
2559                                     "xtype": "ColumnModel",
2560                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2561                                     "|xns": "Roo.grid"
2562                                 }
2563                             ]
2564                         }
2565                     ]
2566                 },
2567                 {
2568                     "region": "center",
2569                     "title": "Stock Tx",
2570                     "xtype": "NestedLayoutPanel",
2571                     "|xns": "Roo",
2572                     "items": [
2573                         {
2574                             "|xns": "Roo",
2575                             "xtype": "BorderLayout",
2576                             "*prop": "layout",
2577                             "items": [
2578                                 {
2579                                     "|xns": "Roo",
2580                                     "xtype": "LayoutRegion",
2581                                     "*prop": "center"
2582                                 },
2583                                 {
2584                                     "*prop": "east",
2585                                     "split": true,
2586                                     "width": 500,
2587                                     "xtype": "LayoutRegion",
2588                                     "|xns": "Roo"
2589                                 },
2590                                 {
2591                                     "listeners": {
2592                                         "|activate": "function() {\n    _this.txpanel = this;\n    if (_this.txgrid) {\n        _this.txgrid.footer.onClick('first');\n    }\n}"
2593                                     },
2594                                     "background": false,
2595                                     "fitContainer": true,
2596                                     "fitToframe": true,
2597                                     "region": "center",
2598                                     "tableName": "invdetail",
2599                                     "title": "invdetail",
2600                                     "xtype": "GridPanel",
2601                                     "|xns": "Roo",
2602                                     "items": [
2603                                         {
2604                                             "listeners": {
2605                                                 "|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}"
2606                                             },
2607                                             "*prop": "grid",
2608                                             "autoExpandColumn": "item_number",
2609                                             "loadMask": true,
2610                                             "xtype": "Grid",
2611                                             "|xns": "Roo.grid",
2612                                             "items": [
2613                                                 {
2614                                                     "|xns": "Roo",
2615                                                     "xtype": "Toolbar",
2616                                                     "*prop": "toolbar",
2617                                                     "items": [
2618                                                         {
2619                                                             "listeners": {
2620                                                                 "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}"
2621                                                             },
2622                                                             "text": "Run Apply Fifo on order",
2623                                                             "xtype": "Button",
2624                                                             "|xns": "Roo.Toolbar"
2625                                                         },
2626                                                         {
2627                                                             "listeners": {
2628                                                                 "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}"
2629                                                             },
2630                                                             "text": "Run Void flagger",
2631                                                             "xtype": "Button",
2632                                                             "|xns": "Roo.Toolbar"
2633                                                         },
2634                                                         {
2635                                                             "listeners": {
2636                                                                 "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}"
2637                                                             },
2638                                                             "text": "Auto Reverse",
2639                                                             "xtype": "Button",
2640                                                             "|xns": "Roo.Toolbar"
2641                                                         }
2642                                                     ]
2643                                                 },
2644                                                 {
2645                                                     "listeners": {
2646                                                         "selectionchange": "function (_self)\n{\n    _this.txdgrid.footer.onClick('first');;\n}"
2647                                                     },
2648                                                     "*prop": "sm",
2649                                                     "singleSelect": true,
2650                                                     "xtype": "RowSelectionModel",
2651                                                     "|xns": "Roo.grid"
2652                                                 },
2653                                                 {
2654                                                     "listeners": {
2655                                                         "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}"
2656                                                     },
2657                                                     "*prop": "dataSource",
2658                                                     "remoteSort": true,
2659                                                     "xtype": "Store",
2660                                                     "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
2661                                                     "|xns": "Roo.data",
2662                                                     "items": [
2663                                                         {
2664                                                             "*prop": "proxy",
2665                                                             "method": "GET",
2666                                                             "xtype": "HttpProxy",
2667                                                             "|url": "baseURL + '/Roo/invdetail.php'",
2668                                                             "|xns": "Roo.data"
2669                                                         },
2670                                                         {
2671                                                             "|xns": "Roo.data",
2672                                                             "xtype": "JsonReader",
2673                                                             "totalProperty": "total",
2674                                                             "root": "data",
2675                                                             "*prop": "reader",
2676                                                             "id": "id",
2677                                                             "|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]"
2678                                                         }
2679                                                     ]
2680                                                 },
2681                                                 {
2682                                                     "*prop": "footer",
2683                                                     "displayInfo": true,
2684                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
2685                                                     "emptyMsg": "No invdetail found",
2686                                                     "pageSize": 9999,
2687                                                     "xtype": "PagingToolbar",
2688                                                     "|xns": "Roo"
2689                                                 },
2690                                                 {
2691                                                     "*prop": "colModel[]",
2692                                                     "dataIndex": "item_number",
2693                                                     "header": "Item",
2694                                                     "width": 75,
2695                                                     "xtype": "ColumnModel",
2696                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2697                                                     "|xns": "Roo.grid"
2698                                                 },
2699                                                 {
2700                                                     "*prop": "colModel[]",
2701                                                     "align": "right",
2702                                                     "dataIndex": "rec_shipped",
2703                                                     "header": "#Ship",
2704                                                     "width": 50,
2705                                                     "xtype": "ColumnModel",
2706                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2707                                                     "|xns": "Roo.grid"
2708                                                 },
2709                                                 {
2710                                                     "*prop": "colModel[]",
2711                                                     "align": "right",
2712                                                     "dataIndex": "rec_returned",
2713                                                     "header": "#Ret",
2714                                                     "width": 50,
2715                                                     "xtype": "ColumnModel",
2716                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2717                                                     "|xns": "Roo.grid"
2718                                                 },
2719                                                 {
2720                                                     "*prop": "colModel[]",
2721                                                     "align": "right",
2722                                                     "dataIndex": "tx_shipped",
2723                                                     "header": "#TX ship",
2724                                                     "width": 50,
2725                                                     "xtype": "ColumnModel",
2726                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2727                                                     "|xns": "Roo.grid"
2728                                                 },
2729                                                 {
2730                                                     "*prop": "colModel[]",
2731                                                     "align": "right",
2732                                                     "dataIndex": "tx_returned",
2733                                                     "header": "#TX ret",
2734                                                     "width": 50,
2735                                                     "xtype": "ColumnModel",
2736                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2737                                                     "|xns": "Roo.grid"
2738                                                 },
2739                                                 {
2740                                                     "*prop": "colModel[]",
2741                                                     "align": "right",
2742                                                     "dataIndex": "tx_total",
2743                                                     "header": "#TX Tot",
2744                                                     "width": 50,
2745                                                     "xtype": "ColumnModel",
2746                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2747                                                     "|xns": "Roo.grid"
2748                                                 },
2749                                                 {
2750                                                     "*prop": "colModel[]",
2751                                                     "align": "right",
2752                                                     "dataIndex": "total_value",
2753                                                     "header": "Value",
2754                                                     "width": 50,
2755                                                     "xtype": "ColumnModel",
2756                                                     "|renderer": "function(v,x,r) { \n\n    return (v*1).toFixed(3);\n}",
2757                                                     "|xns": "Roo.grid"
2758                                                 },
2759                                                 {
2760                                                     "*prop": "colModel[]",
2761                                                     "align": "right",
2762                                                     "dataIndex": "tx_total",
2763                                                     "header": "#Diff",
2764                                                     "width": 50,
2765                                                     "xtype": "ColumnModel",
2766                                                     "|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    }",
2767                                                     "|xns": "Roo.grid"
2768                                                 }
2769                                             ]
2770                                         }
2771                                     ]
2772                                 },
2773                                 {
2774                                     "listeners": {
2775                                         "|activate": "function() {\n    _this.txdpanel = this;\n    if (_this.txdgrid) {\n        _this.txdgrid.footer.onClick('first');\n    }\n}"
2776                                     },
2777                                     "background": false,
2778                                     "fitContainer": true,
2779                                     "fitToframe": true,
2780                                     "region": "east",
2781                                     "tableName": "invdetail",
2782                                     "title": "invdetail",
2783                                     "xtype": "GridPanel",
2784                                     "|xns": "Roo",
2785                                     "items": [
2786                                         {
2787                                             "listeners": {
2788                                                 "|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}",
2789                                                 "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}"
2790                                             },
2791                                             "*prop": "grid",
2792                                             "autoExpandColumn": "invhist_comments",
2793                                             "loadMask": true,
2794                                             "xtype": "Grid",
2795                                             "|xns": "Roo.grid",
2796                                             "items": [
2797                                                 {
2798                                                     "|xns": "Roo",
2799                                                     "xtype": "Toolbar",
2800                                                     "*prop": "toolbar",
2801                                                     "items": [
2802                                                         {
2803                                                             "listeners": {
2804                                                                 "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}"
2805                                                             },
2806                                                             "text": "Duplicate Selected",
2807                                                             "xtype": "Button",
2808                                                             "|xns": "Roo.Toolbar"
2809                                                         },
2810                                                         {
2811                                                             "|xns": "Roo.Toolbar",
2812                                                             "xtype": "Fill"
2813                                                         },
2814                                                         {
2815                                                             "text": "Issue Date",
2816                                                             "xtype": "TextItem",
2817                                                             "|xns": "Roo.Toolbar"
2818                                                         },
2819                                                         {
2820                                                             "listeners": {
2821                                                                 "render": "function (_self)\n{\n    _this.dateSel = _self;\n}"
2822                                                             },
2823                                                             "allowBlank": false,
2824                                                             "fieldLabel": "Issue Date",
2825                                                             "format": "Y-m-d",
2826                                                             "name": "issue_date",
2827                                                             "width": 150,
2828                                                             "xtype": "DateField",
2829                                                             "|xns": "Roo.form"
2830                                                         },
2831                                                         {
2832                                                             "listeners": {
2833                                                                 "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}"
2834                                                             },
2835                                                             "text": "Reverse Selected",
2836                                                             "xtype": "Button",
2837                                                             "|xns": "Roo.Toolbar"
2838                                                         }
2839                                                     ]
2840                                                 },
2841                                                 {
2842                                                     "listeners": {
2843                                                         "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}"
2844                                                     },
2845                                                     "*prop": "dataSource",
2846                                                     "remoteSort": true,
2847                                                     "xtype": "Store",
2848                                                     "|sortInfo": "{ field : 'invdetail_id', direction: 'ASC' }",
2849                                                     "|xns": "Roo.data",
2850                                                     "items": [
2851                                                         {
2852                                                             "*prop": "proxy",
2853                                                             "method": "GET",
2854                                                             "xtype": "HttpProxy",
2855                                                             "|url": "baseURL + '/Roo/invdetail.php'",
2856                                                             "|xns": "Roo.data"
2857                                                         },
2858                                                         {
2859                                                             "|xns": "Roo.data",
2860                                                             "xtype": "JsonReader",
2861                                                             "totalProperty": "total",
2862                                                             "root": "data",
2863                                                             "*prop": "reader",
2864                                                             "id": "id",
2865                                                             "|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]"
2866                                                         }
2867                                                     ]
2868                                                 },
2869                                                 {
2870                                                     "*prop": "footer",
2871                                                     "displayInfo": true,
2872                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
2873                                                     "emptyMsg": "No invdetail found",
2874                                                     "pageSize": 9999,
2875                                                     "xtype": "PagingToolbar",
2876                                                     "|xns": "Roo"
2877                                                 },
2878                                                 {
2879                                                     "*prop": "colModel[]",
2880                                                     "dataIndex": "invdetail_id",
2881                                                     "header": "TX#",
2882                                                     "width": 60,
2883                                                     "xtype": "ColumnModel",
2884                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2885                                                     "|xns": "Roo.grid"
2886                                                 },
2887                                                 {
2888                                                     "*prop": "colModel[]",
2889                                                     "dataIndex": "invhist_transdate",
2890                                                     "header": "Date",
2891                                                     "width": 75,
2892                                                     "xtype": "ColumnModel",
2893                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2894                                                     "|xns": "Roo.grid"
2895                                                 },
2896                                                 {
2897                                                     "*prop": "colModel[]",
2898                                                     "dataIndex": "invhist_ordnumber",
2899                                                     "header": "Ref#",
2900                                                     "width": 75,
2901                                                     "xtype": "ColumnModel",
2902                                                     "|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 }",
2903                                                     "|xns": "Roo.grid"
2904                                                 },
2905                                                 {
2906                                                     "*prop": "colModel[]",
2907                                                     "dataIndex": "location_name",
2908                                                     "header": "TX#",
2909                                                     "width": 60,
2910                                                     "xtype": "ColumnModel",
2911                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2912                                                     "|xns": "Roo.grid"
2913                                                 },
2914                                                 {
2915                                                     "*prop": "colModel[]",
2916                                                     "dataIndex": "invhist_comments",
2917                                                     "header": "Notes",
2918                                                     "width": 75,
2919                                                     "xtype": "ColumnModel",
2920                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2921                                                     "|xns": "Roo.grid"
2922                                                 },
2923                                                 {
2924                                                     "*prop": "colModel[]",
2925                                                     "align": "right",
2926                                                     "dataIndex": "invdetail_qty",
2927                                                     "header": "Qty Changed",
2928                                                     "width": 50,
2929                                                     "xtype": "ColumnModel",
2930                                                     "|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}",
2931                                                     "|xns": "Roo.grid"
2932                                                 },
2933                                                 {
2934                                                     "*prop": "colModel[]",
2935                                                     "align": "right",
2936                                                     "dataIndex": "invhist_value_before",
2937                                                     "header": "Qty Changed",
2938                                                     "width": 75,
2939                                                     "xtype": "ColumnModel",
2940                                                     "|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}",
2941                                                     "|xns": "Roo.grid"
2942                                                 },
2943                                                 {
2944                                                     "*prop": "colModel[]",
2945                                                     "dataIndex": "invhist_posted",
2946                                                     "header": "Posted",
2947                                                     "width": 40,
2948                                                     "xtype": "ColumnModel",
2949                                                     "|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 }",
2950                                                     "|xns": "Roo.grid"
2951                                                 }
2952                                             ]
2953                                         }
2954                                     ]
2955                                 }
2956                             ]
2957                         }
2958                     ]
2959                 },
2960                 {
2961                     "region": "center",
2962                     "title": "GL Tx",
2963                     "xtype": "NestedLayoutPanel",
2964                     "|xns": "Roo",
2965                     "items": [
2966                         {
2967                             "|xns": "Roo",
2968                             "xtype": "BorderLayout",
2969                             "*prop": "layout",
2970                             "items": [
2971                                 {
2972                                     "|xns": "Roo",
2973                                     "xtype": "LayoutRegion",
2974                                     "*prop": "center"
2975                                 },
2976                                 {
2977                                     "*prop": "east",
2978                                     "split": true,
2979                                     "width": 500,
2980                                     "xtype": "LayoutRegion",
2981                                     "|xns": "Roo"
2982                                 },
2983                                 {
2984                                     "listeners": {
2985                                         "|activate": "function() {\n    _this.gltxpanel = this;\n    if (_this.gltxgrid) {\n        _this.gltxgrid.footer.onClick('first');\n    }\n}"
2986                                     },
2987                                     "background": false,
2988                                     "fitContainer": true,
2989                                     "fitToframe": true,
2990                                     "region": "center",
2991                                     "tableName": "invdetail",
2992                                     "title": "invdetail",
2993                                     "xtype": "GridPanel",
2994                                     "|xns": "Roo",
2995                                     "items": [
2996                                         {
2997                                             "listeners": {
2998                                                 "|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}",
2999                                                 "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}"
3000                                             },
3001                                             "*prop": "grid",
3002                                             "autoExpandColumn": "gltrans_accnt_id_accnt_descrip",
3003                                             "loadMask": true,
3004                                             "xtype": "Grid",
3005                                             "|xns": "Roo.grid",
3006                                             "items": [
3007                                                 {
3008                                                     "listeners": {
3009                                                         "selectionchange": "function (_self)\n{\n    _this.gltxdgrid.footer.onClick('first');;\n}"
3010                                                     },
3011                                                     "*prop": "sm",
3012                                                     "singleSelect": true,
3013                                                     "xtype": "RowSelectionModel",
3014                                                     "|xns": "Roo.grid"
3015                                                 },
3016                                                 {
3017                                                     "listeners": {
3018                                                         "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}"
3019                                                     },
3020                                                     "*prop": "dataSource",
3021                                                     "remoteSort": true,
3022                                                     "xtype": "Store",
3023                                                     "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
3024                                                     "|xns": "Roo.data",
3025                                                     "items": [
3026                                                         {
3027                                                             "*prop": "proxy",
3028                                                             "method": "GET",
3029                                                             "xtype": "HttpProxy",
3030                                                             "|url": "baseURL + '/Roo/gltrans.php'",
3031                                                             "|xns": "Roo.data"
3032                                                         },
3033                                                         {
3034                                                             "|xns": "Roo.data",
3035                                                             "xtype": "JsonReader",
3036                                                             "totalProperty": "total",
3037                                                             "root": "data",
3038                                                             "*prop": "reader",
3039                                                             "id": "id",
3040                                                             "|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]"
3041                                                         }
3042                                                     ]
3043                                                 },
3044                                                 {
3045                                                     "*prop": "footer",
3046                                                     "displayInfo": true,
3047                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
3048                                                     "emptyMsg": "No invdetail found",
3049                                                     "pageSize": 9999,
3050                                                     "xtype": "PagingToolbar",
3051                                                     "|xns": "Roo",
3052                                                     "items": [
3053                                                         {
3054                                                             "listeners": {
3055                                                                 "render": "function (_self)\n{\n    _this.glsalesbtn = _self;\n}",
3056                                                                 "click": "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
3057                                                             },
3058                                                             "enableToggle": true,
3059                                                             "pressed": true,
3060                                                             "text": "Split sales",
3061                                                             "xtype": "Button",
3062                                                             "|xns": "Roo.Toolbar"
3063                                                         }
3064                                                     ]
3065                                                 },
3066                                                 {
3067                                                     "*prop": "colModel[]",
3068                                                     "dataIndex": "gltrans_as_summary",
3069                                                     "header": "Summary",
3070                                                     "width": 50,
3071                                                     "xtype": "ColumnModel",
3072                                                     "|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 }",
3073                                                     "|xns": "Roo.grid"
3074                                                 },
3075                                                 {
3076                                                     "*prop": "colModel[]",
3077                                                     "dataIndex": "gltrans_accnt_id_accnt_descrip",
3078                                                     "header": "Account",
3079                                                     "width": 75,
3080                                                     "xtype": "ColumnModel",
3081                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3082                                                     "|xns": "Roo.grid"
3083                                                 },
3084                                                 {
3085                                                     "*prop": "colModel[]",
3086                                                     "align": "right",
3087                                                     "dataIndex": "gltrans_amount_credit",
3088                                                     "header": "Credit",
3089                                                     "width": 75,
3090                                                     "xtype": "ColumnModel",
3091                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,3)); }",
3092                                                     "|xns": "Roo.grid"
3093                                                 },
3094                                                 {
3095                                                     "*prop": "colModel[]",
3096                                                     "align": "right",
3097                                                     "dataIndex": "gltrans_amount_debit",
3098                                                     "header": "Debit",
3099                                                     "width": 75,
3100                                                     "xtype": "ColumnModel",
3101                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3102                                                     "|xns": "Roo.grid"
3103                                                 },
3104                                                 {
3105                                                     "*prop": "colModel[]",
3106                                                     "align": "right",
3107                                                     "dataIndex": "gltrans_amount_total",
3108                                                     "header": "Sum",
3109                                                     "width": 75,
3110                                                     "xtype": "ColumnModel",
3111                                                     "|renderer": "function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }",
3112                                                     "|xns": "Roo.grid"
3113                                                 },
3114                                                 {
3115                                                     "*prop": "colModel[]",
3116                                                     "align": "right",
3117                                                     "dataIndex": "gltrans_amount_total_unposted",
3118                                                     "header": "Unposted",
3119                                                     "width": 75,
3120                                                     "xtype": "ColumnModel",
3121                                                     "|renderer": "function(v) { return String.format('<span style=\"color:red\">{0}</span>', Roo.util.Format.number(v,3)); }",
3122                                                     "|xns": "Roo.grid"
3123                                                 }
3124                                             ]
3125                                         }
3126                                     ]
3127                                 },
3128                                 {
3129                                     "listeners": {
3130                                         "|activate": "function() {\n    _this.gltxdpanel = this;\n    if (_this.gltxdgrid) {\n        _this.gltxdgrid.footer.onClick('first');\n    }\n}"
3131                                     },
3132                                     "background": false,
3133                                     "fitContainer": true,
3134                                     "fitToframe": true,
3135                                     "region": "east",
3136                                     "tableName": "invdetail",
3137                                     "title": "invdetail",
3138                                     "xtype": "GridPanel",
3139                                     "|xns": "Roo",
3140                                     "items": [
3141                                         {
3142                                             "listeners": {
3143                                                 "|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}",
3144                                                 "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}"
3145                                             },
3146                                             "*prop": "grid",
3147                                             "autoExpandColumn": "gltrans_notes",
3148                                             "loadMask": true,
3149                                             "xtype": "Grid",
3150                                             "|xns": "Roo.grid",
3151                                             "items": [
3152                                                 {
3153                                                     "listeners": {
3154                                                         "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}"
3155                                                     },
3156                                                     "*prop": "dataSource",
3157                                                     "remoteSort": true,
3158                                                     "xtype": "Store",
3159                                                     "|sortInfo": "{ field : 'gltrans_docnumber', direction: 'ASC' }",
3160                                                     "|xns": "Roo.data",
3161                                                     "items": [
3162                                                         {
3163                                                             "*prop": "proxy",
3164                                                             "method": "GET",
3165                                                             "xtype": "HttpProxy",
3166                                                             "|url": "baseURL + '/Roo/gltrans.php'",
3167                                                             "|xns": "Roo.data"
3168                                                         },
3169                                                         {
3170                                                             "|xns": "Roo.data",
3171                                                             "xtype": "JsonReader",
3172                                                             "totalProperty": "total",
3173                                                             "root": "data",
3174                                                             "*prop": "reader",
3175                                                             "id": "id",
3176                                                             "|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]"
3177                                                         }
3178                                                     ]
3179                                                 },
3180                                                 {
3181                                                     "*prop": "footer",
3182                                                     "displayInfo": true,
3183                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
3184                                                     "emptyMsg": "No invdetail found",
3185                                                     "pageSize": 9999,
3186                                                     "xtype": "PagingToolbar",
3187                                                     "|xns": "Roo",
3188                                                     "items": [
3189                                                         {
3190                                                             "listeners": {
3191                                                                 "click": "function (_self, e)\n{\n    new Pman.Download( {\n        grid : _this.gltxdgrid\n    \n    });\n}"
3192                                                             },
3193                                                             "text": "Download",
3194                                                             "xtype": "Button",
3195                                                             "|xns": "Roo.Toolbar"
3196                                                         }
3197                                                     ]
3198                                                 },
3199                                                 {
3200                                                     "*prop": "colModel[]",
3201                                                     "dataIndex": "gltrans_id",
3202                                                     "header": "Ref#",
3203                                                     "sortable": true,
3204                                                     "width": 75,
3205                                                     "xtype": "ColumnModel",
3206                                                     "|renderer": "function(v) { return String.format('{0}', v ); }",
3207                                                     "|xns": "Roo.grid"
3208                                                 },
3209                                                 {
3210                                                     "*prop": "colModel[]",
3211                                                     "dataIndex": "gltrans_date",
3212                                                     "header": "Date",
3213                                                     "width": 75,
3214                                                     "xtype": "ColumnModel",
3215                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
3216                                                     "|xns": "Roo.grid"
3217                                                 },
3218                                                 {
3219                                                     "*prop": "colModel[]",
3220                                                     "dataIndex": "gltrans_docnumber",
3221                                                     "header": "Doc#",
3222                                                     "width": 75,
3223                                                     "xtype": "ColumnModel",
3224                                                     "|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}",
3225                                                     "|xns": "Roo.grid"
3226                                                 },
3227                                                 {
3228                                                     "*prop": "colModel[]",
3229                                                     "dataIndex": "gltrans_source",
3230                                                     "header": "Source",
3231                                                     "width": 50,
3232                                                     "xtype": "ColumnModel",
3233                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3234                                                     "|xns": "Roo.grid"
3235                                                 },
3236                                                 {
3237                                                     "*prop": "colModel[]",
3238                                                     "dataIndex": "gltrans_notes",
3239                                                     "header": "Notes",
3240                                                     "width": 75,
3241                                                     "xtype": "ColumnModel",
3242                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3243                                                     "|xns": "Roo.grid"
3244                                                 },
3245                                                 {
3246                                                     "*prop": "colModel[]",
3247                                                     "align": "right",
3248                                                     "dataIndex": "gltrans_amount",
3249                                                     "header": "Amount",
3250                                                     "width": 75,
3251                                                     "xtype": "ColumnModel",
3252                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3253                                                     "|xns": "Roo.grid"
3254                                                 },
3255                                                 {
3256                                                     "*prop": "colModel[]",
3257                                                     "dataIndex": "gltrans_posted",
3258                                                     "header": "Posted",
3259                                                     "width": 50,
3260                                                     "xtype": "ColumnModel",
3261                                                     "|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 }",
3262                                                     "|xns": "Roo.grid"
3263                                                 }
3264                                             ]
3265                                         }
3266                                     ]
3267                                 }
3268                             ]
3269                         }
3270                     ]
3271                 },
3272                 {
3273                     "listeners": {
3274                         "|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}"
3275                     },
3276                     "background": true,
3277                     "fitContainer": true,
3278                     "fitToframe": true,
3279                     "region": "center",
3280                     "tableName": "coitem",
3281                     "title": "Profit",
3282                     "xtype": "GridPanel",
3283                     "|xns": "Roo",
3284                     "items": [
3285                         {
3286                             "listeners": {
3287                                 "|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}"
3288                             },
3289                             "*prop": "grid",
3290                             "autoExpandColumn": "item_number",
3291                             "loadMask": true,
3292                             "xtype": "Grid",
3293                             "|xns": "Roo.grid",
3294                             "items": [
3295                                 {
3296                                     "listeners": {
3297                                         "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}"
3298                                     },
3299                                     "*prop": "dataSource",
3300                                     "remoteSort": true,
3301                                     "xtype": "Store",
3302                                     "|sortInfo": "{ field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' }",
3303                                     "|xns": "Roo.data",
3304                                     "items": [
3305                                         {
3306                                             "*prop": "proxy",
3307                                             "method": "GET",
3308                                             "xtype": "HttpProxy",
3309                                             "|url": "baseURL + '/Roo/coitem.php'",
3310                                             "|xns": "Roo.data"
3311                                         },
3312                                         {
3313                                             "|xns": "Roo.data",
3314                                             "xtype": "JsonReader",
3315                                             "totalProperty": "total",
3316                                             "root": "data",
3317                                             "*prop": "reader",
3318                                             "id": "id",
3319                                             "|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]"
3320                                         }
3321                                     ]
3322                                 },
3323                                 {
3324                                     "*prop": "footer",
3325                                     "displayInfo": true,
3326                                     "displayMsg": "Displaying coitem{0} - {1} of {2}",
3327                                     "emptyMsg": "No coitem found",
3328                                     "pageSize": 25,
3329                                     "xtype": "PagingToolbar",
3330                                     "|xns": "Roo"
3331                                 },
3332                                 {
3333                                     "*prop": "colModel[]",
3334                                     "dataIndex": "item_number",
3335                                     "header": "Item Code",
3336                                     "width": 75,
3337                                     "xtype": "ColumnModel",
3338                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3339                                     "|xns": "Roo.grid"
3340                                 },
3341                                 {
3342                                     "*prop": "colModel[]",
3343                                     "dataIndex": "calc_subtotal",
3344                                     "header": "SubTotal",
3345                                     "width": 200,
3346                                     "xtype": "ColumnModel",
3347                                     "|renderer": "function(v) {\n\n\n     return Roo.util.Format.number( v, 2);\n  }",
3348                                     "|xns": "Roo.grid"
3349                                 },
3350                                 {
3351                                     "*prop": "colModel[]",
3352                                     "dataIndex": "calc_cost_total",
3353                                     "header": "Cost of goods",
3354                                     "width": 200,
3355                                     "xtype": "ColumnModel",
3356                                     "|renderer": "function(v) {\n\n    return Roo.util.Format.number( v, 2);\n  }",
3357                                     "|xns": "Roo.grid"
3358                                 },
3359                                 {
3360                                     "*prop": "colModel[]",
3361                                     "dataIndex": "profit",
3362                                     "header": "Profit",
3363                                     "width": 200,
3364                                     "xtype": "ColumnModel",
3365                                     "|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}",
3366                                     "|xns": "Roo.grid"
3367                                 }
3368                             ]
3369                         }
3370                     ]
3371                 },
3372                 {
3373                     "listeners": {
3374                         "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}",
3375                         "render": "function (_self)\n{\n    _this.reversalBtn = _self;\n}"
3376                     },
3377                     "*prop": "buttons[]",
3378                     "text": "Create CM reversal",
3379                     "xtype": "Button",
3380                     "|xns": "Roo"
3381                 },
3382                 {
3383                     "listeners": {
3384                         "click": "function (_self, e)\n{\n      if (_this.grid)  _this.grid.stopEditing();\n    _this.dialog.hide();\n}"
3385                     },
3386                     "*prop": "buttons[]",
3387                     "text": "Cancel",
3388                     "xtype": "Button",
3389                     "|xns": "Roo"
3390                 },
3391                 {
3392                     "listeners": {
3393                         "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}",
3394                         "render": "function (_self)\n{\n    _this.saveBtn = _self;\n}"
3395                     },
3396                     "*prop": "buttons[]",
3397                     "text": "Save",
3398                     "xtype": "Button",
3399                     "|xns": "Roo"
3400                 }
3401             ]
3402         }
3403     ],
3404     "permname": "",
3405     "modOrder": "001"
3406 }