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        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        }  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                                                     "listeners": {
1908                                                         "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}"
1909                                                     },
1910                                                     "*prop": "dataSource",
1911                                                     ".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\"}",
1912                                                     "remoteSort": true,
1913                                                     "xtype": "Store",
1914                                                     "|sortInfo": "{ field : 'shiphead_shipvia', direction: 'ASC' }",
1915                                                     "|xns": "Roo.data",
1916                                                     "items": [
1917                                                         {
1918                                                             "*prop": "proxy",
1919                                                             "xtype": "HttpProxy",
1920                                                             "method": "GET",
1921                                                             "|url": "baseURL + '/Roo/shiphead.php'",
1922                                                             "|xns": "Roo.data"
1923                                                         },
1924                                                         {
1925                                                             "|xns": "Roo.data",
1926                                                             "xtype": "JsonReader",
1927                                                             "totalProperty": "total",
1928                                                             "root": "data",
1929                                                             ".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\"}",
1930                                                             "*prop": "reader",
1931                                                             "id": "id",
1932                                                             "|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]"
1933                                                         }
1934                                                     ]
1935                                                 },
1936                                                 {
1937                                                     "*prop": "toolbar",
1938                                                     "xtype": "Toolbar",
1939                                                     "|xns": "Roo",
1940                                                     "items": [
1941                                                         {
1942                                                             "listeners": {
1943                                                                 "|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}"
1944                                                             },
1945                                                             "cls": "x-btn-text-icon",
1946                                                             "text": "Confirm Shipment",
1947                                                             "xtype": "Button",
1948                                                             "|icon": "rootURL + '/Pman/templates/images/lock.gif'",
1949                                                             "|xns": "Roo.Toolbar"
1950                                                         },
1951                                                         {
1952                                                             "listeners": {
1953                                                                 "|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}"
1954                                                             },
1955                                                             "cls": "x-btn-text-icon",
1956                                                             "text": "Download (as xls)",
1957                                                             "xtype": "Button",
1958                                                             "|icon": "rootURL + '/Pman/templates/images/save.gif'",
1959                                                             "|xns": "Roo.Toolbar"
1960                                                         },
1961                                                         {
1962                                                             "listeners": {
1963                                                                 "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}"
1964                                                             },
1965                                                             "cls": "x-btn-text-icon",
1966                                                             "text": "Print Picking Slip",
1967                                                             "xtype": "Button",
1968                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
1969                                                             "|xns": "Roo.Toolbar"
1970                                                         },
1971                                                         {
1972                                                             "listeners": {
1973                                                                 "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}"
1974                                                             },
1975                                                             "cls": "x-btn-text-icon",
1976                                                             "text": "Print Delivery Note",
1977                                                             "xtype": "Button",
1978                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
1979                                                             "|xns": "Roo.Toolbar"
1980                                                         },
1981                                                         {
1982                                                             "xtype": "Fill",
1983                                                             "|xns": "Roo.Toolbar"
1984                                                         },
1985                                                         {
1986                                                             "listeners": {
1987                                                                 "|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}",
1988                                                                 "render": "function (_self)\n{\n  _this.addShipmentBtn = _self;\n}"
1989                                                             },
1990                                                             "cls": "x-btn-text-icon",
1991                                                             "text": "Add",
1992                                                             "xtype": "Button",
1993                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
1994                                                             "|xns": "Roo.Toolbar"
1995                                                         },
1996                                                         {
1997                                                             "listeners": {
1998                                                                 "|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        "
1999                                                             },
2000                                                             "cls": "x-btn-text-icon",
2001                                                             "text": "Void / Unconfirm",
2002                                                             "xtype": "Button",
2003                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2004                                                             "|xns": "Roo.Toolbar"
2005                                                         }
2006                                                     ]
2007                                                 },
2008                                                 {
2009                                                     "*prop": "colModel[]",
2010                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_number\",\"columnshort\":\"shiphead_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2011                                                     "dataIndex": "shiphead_number",
2012                                                     "header": "number",
2013                                                     "width": 80,
2014                                                     "xtype": "ColumnModel",
2015                                                     "|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 }",
2016                                                     "|xns": "Roo.grid"
2017                                                 },
2018                                                 {
2019                                                     "*prop": "colModel[]",
2020                                                     "dataIndex": "shiphead_location_id_location_name",
2021                                                     "header": "From Location",
2022                                                     "width": 100,
2023                                                     "xtype": "ColumnModel",
2024                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2025                                                     "|xns": "Roo.grid"
2026                                                 },
2027                                                 {
2028                                                     "*prop": "colModel[]",
2029                                                     "dataIndex": "shiphead_shipto_id_shipto_name",
2030                                                     "header": "Ship to",
2031                                                     "width": 100,
2032                                                     "xtype": "ColumnModel",
2033                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2034                                                     "|xns": "Roo.grid"
2035                                                 },
2036                                                 {
2037                                                     "xtype": "ColumnModel",
2038                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_shipdate\",\"columnshort\":\"shiphead_shipdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2039                                                     "header": "shipdate",
2040                                                     "width": 75,
2041                                                     "dataIndex": "shiphead_shipdate",
2042                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
2043                                                     "|xns": "Roo.grid",
2044                                                     "*prop": "colModel[]"
2045                                                 },
2046                                                 {
2047                                                     "*prop": "colModel[]",
2048                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_sfstatus\",\"columnshort\":\"shiphead_sfstatus\",\"ctype\":\"bpchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2049                                                     "dataIndex": "shiphead_sfstatus",
2050                                                     "header": "Status",
2051                                                     "width": 50,
2052                                                     "xtype": "ColumnModel",
2053                                                     "|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}",
2054                                                     "|xns": "Roo.grid"
2055                                                 },
2056                                                 {
2057                                                     "xtype": "ColumnModel",
2058                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_shipvia\",\"columnshort\":\"shiphead_shipvia\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}",
2059                                                     "header": "shipvia",
2060                                                     "width": 200,
2061                                                     "dataIndex": "shiphead_shipvia",
2062                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2063                                                     "|xns": "Roo.grid",
2064                                                     "*prop": "colModel[]"
2065                                                 },
2066                                                 {
2067                                                     "xtype": "ColumnModel",
2068                                                     ".builderCfg": "{\"table\":\"shiphead\",\"column\":\"shiphead_tracknum\",\"columnshort\":\"shiphead_tracknum\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2069                                                     "header": "tracknum",
2070                                                     "width": 200,
2071                                                     "dataIndex": "shiphead_tracknum",
2072                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2073                                                     "|xns": "Roo.grid",
2074                                                     "*prop": "colModel[]"
2075                                                 }
2076                                             ]
2077                                         }
2078                                     ]
2079                                 },
2080                                 {
2081                                     "listeners": {
2082                                         "|activate": "function() {\n    _this.invpanel = this;\n    if (_this.invgrid) {\n        _this.invgrid.ds.load({});\n    }\n}"
2083                                     },
2084                                     "background": false,
2085                                     "fitContainer": true,
2086                                     "fitToframe": true,
2087                                     "region": "center",
2088                                     "tableName": "cobmisc",
2089                                     "title": "Invoices",
2090                                     "xtype": "GridPanel",
2091                                     "|xns": "Roo",
2092                                     "items": [
2093                                         {
2094                                             "listeners": {
2095                                                 "|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}",
2096                                                 "|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"
2097                                             },
2098                                             "*prop": "grid",
2099                                             ".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\"}",
2100                                             "autoExpandColumn": "invchead_invcnumber",
2101                                             "loadMask": true,
2102                                             "xtype": "Grid",
2103                                             "|xns": "Roo.grid",
2104                                             "items": [
2105                                                 {
2106                                                     "listeners": {
2107                                                         "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}",
2108                                                         "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}"
2109                                                     },
2110                                                     "*prop": "dataSource",
2111                                                     "remoteSort": true,
2112                                                     "xtype": "Store",
2113                                                     "|sortInfo": "{ field : 'invchead_invcnumber', direction: 'ASC' }",
2114                                                     "|xns": "Roo.data",
2115                                                     "items": [
2116                                                         {
2117                                                             "*prop": "proxy",
2118                                                             "method": "GET",
2119                                                             "xtype": "HttpProxy",
2120                                                             "|url": "baseURL + '/Roo/cobmisc.php'",
2121                                                             "|xns": "Roo.data"
2122                                                         },
2123                                                         {
2124                                                             "*prop": "reader",
2125                                                             ".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\"}",
2126                                                             "id": "id",
2127                                                             "root": "data",
2128                                                             "totalProperty": "total",
2129                                                             "xtype": "JsonReader",
2130                                                             "|fields": "[\n    {\n        'name': 'invchead_invcnumber',\n        'type': 'string'\n    },\n    {\n        'name': 'invchead_invcdate',\n        'type': 'date'\n    }\n]",
2131                                                             "|xns": "Roo.data"
2132                                                         }
2133                                                     ]
2134                                                 },
2135                                                 {
2136                                                     "*prop": "toolbar",
2137                                                     "xtype": "Toolbar",
2138                                                     "|xns": "Roo",
2139                                                     "items": [
2140                                                         {
2141                                                             "listeners": {
2142                                                                 "|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}"
2143                                                             },
2144                                                             "cls": "x-btn-text-icon",
2145                                                             "text": "Post Invoice",
2146                                                             "xtype": "Button",
2147                                                             "|icon": "rootURL + '/Pman/templates/images/lock.gif'",
2148                                                             "|xns": "Roo.Toolbar"
2149                                                         },
2150                                                         {
2151                                                             "cls": "x-btn-text-icon",
2152                                                             "text": "Print",
2153                                                             "xtype": "Button",
2154                                                             "|icon": "rootURL + '/Pman/templates/images/pdf.gif'",
2155                                                             "|xns": "Roo.Toolbar",
2156                                                             "items": [
2157                                                                 {
2158                                                                     "|xns": "Roo.menu",
2159                                                                     "xtype": "Menu",
2160                                                                     "*prop": "menu",
2161                                                                     "items": [
2162                                                                         {
2163                                                                             "listeners": {
2164                                                                                 "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}"
2165                                                                             },
2166                                                                             "text": "Print Standard Invoice",
2167                                                                             "xtype": "Item",
2168                                                                             "|xns": "Roo.menu"
2169                                                                         },
2170                                                                         {
2171                                                                             "listeners": {
2172                                                                                 "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} "
2173                                                                             },
2174                                                                             "text": "Print Chinese Invoice With GST in line item",
2175                                                                             "xtype": "Item",
2176                                                                             "|hidden": "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2177                                                                             "|xns": "Roo.menu"
2178                                                                         },
2179                                                                         {
2180                                                                             "listeners": {
2181                                                                                 "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} "
2182                                                                             },
2183                                                                             "text": "Print Chinese Invoice",
2184                                                                             "xtype": "Item",
2185                                                                             "|hidden": "!(baseURL.match(/(hk\\.php|cn\\.php)$/))",
2186                                                                             "|xns": "Roo.menu"
2187                                                                         },
2188                                                                         {
2189                                                                             "listeners": {
2190                                                                                 "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} "
2191                                                                             },
2192                                                                             "text": "Print Aus - GST included Invoice",
2193                                                                             "xtype": "Item",
2194                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2195                                                                             "|xns": "Roo.menu"
2196                                                                         },
2197                                                                         {
2198                                                                             "listeners": {
2199                                                                                 "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}"
2200                                                                             },
2201                                                                             "text": "Print Bambini Pronto Invoice",
2202                                                                             "xtype": "Item",
2203                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2204                                                                             "|xns": "Roo.menu"
2205                                                                         },
2206                                                                         {
2207                                                                             "listeners": {
2208                                                                                 "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} "
2209                                                                             },
2210                                                                             "text": "Print Bambini Pro Forma Invoice",
2211                                                                             "xtype": "Item",
2212                                                                             "|hidden": "!(baseURL.match(/au\\.php$/))",
2213                                                                             "|xns": "Roo.menu"
2214                                                                         },
2215                                                                         {
2216                                                                             "listeners": {
2217                                                                                 "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}"
2218                                                                             },
2219                                                                             "text": "Print Shipping / Commercial Invoice",
2220                                                                             "xtype": "Item",
2221                                                                             "|hidden": "!( baseURL.match(/au\\.php$/)) ",
2222                                                                             "|xns": "Roo.menu"
2223                                                                         }
2224                                                                     ]
2225                                                                 }
2226                                                             ]
2227                                                         },
2228                                                         {
2229                                                             "cls": "x-btn-text-icon",
2230                                                             "text": "Payments / Refunds / Credit Memos",
2231                                                             "xtype": "Button",
2232                                                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
2233                                                             "|xns": "Roo.Toolbar",
2234                                                             "items": [
2235                                                                 {
2236                                                                     "|xns": "Roo.menu",
2237                                                                     "xtype": "Menu",
2238                                                                     "*prop": "menu",
2239                                                                     "items": [
2240                                                                         {
2241                                                                             "listeners": {
2242                                                                                 "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"
2243                                                                             },
2244                                                                             "cls": "x-btn-text-icon",
2245                                                                             "text": "Receive Payment",
2246                                                                             "xtype": "Item",
2247                                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2248                                                                             "|xns": "Roo.menu"
2249                                                                         },
2250                                                                         {
2251                                                                             "listeners": {
2252                                                                                 "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"
2253                                                                             },
2254                                                                             "cls": "x-btn-text-icon",
2255                                                                             "text": "Issue Refund",
2256                                                                             "xtype": "Item",
2257                                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2258                                                                             "|xns": "Roo.menu"
2259                                                                         },
2260                                                                         {
2261                                                                             "|xns": "Roo.menu",
2262                                                                             "xtype": "Separator"
2263                                                                         },
2264                                                                         {
2265                                                                             "listeners": {
2266                                                                                 "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"
2267                                                                             },
2268                                                                             "cls": "x-btn-text-icon",
2269                                                                             "text": "Void Payment",
2270                                                                             "xtype": "Item",
2271                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2272                                                                             "|xns": "Roo.menu"
2273                                                                         },
2274                                                                         {
2275                                                                             "listeners": {
2276                                                                                 "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"
2277                                                                             },
2278                                                                             "cls": "x-btn-text-icon",
2279                                                                             "text": "Void Refund",
2280                                                                             "xtype": "Item",
2281                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2282                                                                             "|xns": "Roo.menu"
2283                                                                         },
2284                                                                         {
2285                                                                             "listeners": {
2286                                                                                 "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"
2287                                                                             },
2288                                                                             "cls": "x-btn-text-icon",
2289                                                                             "text": "Void Credit Memo",
2290                                                                             "xtype": "Item",
2291                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2292                                                                             "|xns": "Roo.menu"
2293                                                                         }
2294                                                                     ]
2295                                                                 }
2296                                                             ]
2297                                                         },
2298                                                         {
2299                                                             "xtype": "Fill",
2300                                                             "|xns": "Roo.Toolbar"
2301                                                         },
2302                                                         {
2303                                                             "listeners": {
2304                                                                 "|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}",
2305                                                                 "render": "function (_self)\n{\n  _this.addInvoiceBtn = _self;\n}"
2306                                                             },
2307                                                             "cls": "x-btn-text-icon",
2308                                                             "text": "Add",
2309                                                             "xtype": "Button",
2310                                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
2311                                                             "|xns": "Roo.Toolbar"
2312                                                         },
2313                                                         {
2314                                                             "listeners": {
2315                                                                 "|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}"
2316                                                             },
2317                                                             "cls": "x-btn-text-icon",
2318                                                             "text": "Void / Unpost",
2319                                                             "xtype": "Button",
2320                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
2321                                                             "|xns": "Roo.Toolbar"
2322                                                         }
2323                                                     ]
2324                                                 },
2325                                                 {
2326                                                     "*prop": "colModel[]",
2327                                                     "dataIndex": "cobmisc_invchead_id_invchead_invcnumber",
2328                                                     "header": "Invoice #",
2329                                                     "width": 100,
2330                                                     "xtype": "ColumnModel",
2331                                                     "|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}",
2332                                                     "|xns": "Roo.grid"
2333                                                 },
2334                                                 {
2335                                                     "*prop": "colModel[]",
2336                                                     ".builderCfg": "{\"table\":\"invchead\",\"column\":\"invchead_invcdate\",\"columnshort\":\"invchead_invcdate\",\"ctype\":\"date\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2337                                                     "dataIndex": "cobmisc_invcdate",
2338                                                     "header": "invcdate",
2339                                                     "width": 75,
2340                                                     "xtype": "ColumnModel",
2341                                                     "|renderer": "function(v,x,r) { \n\n        return String.format('{0}', v && r.data.cobmisc_id > 0 ? v.format('d/M/Y') : ''); \n}",
2342                                                     "|xns": "Roo.grid"
2343                                                 },
2344                                                 {
2345                                                     "*prop": "colModel[]",
2346                                                     "align": "right",
2347                                                     "dataIndex": "cobmisc_qty",
2348                                                     "header": "Qty",
2349                                                     "width": 50,
2350                                                     "xtype": "ColumnModel",
2351                                                     "|renderer": "function(v) { return String.format('{0}', v ? parseInt(v) : 0); }",
2352                                                     "|xns": "Roo.grid"
2353                                                 },
2354                                                 {
2355                                                     "*prop": "colModel[]",
2356                                                     "align": "right",
2357                                                     "dataIndex": "cobmisc_itemcost",
2358                                                     "header": "Item Cost",
2359                                                     "width": 75,
2360                                                     "xtype": "ColumnModel",
2361                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : 0); }",
2362                                                     "|xns": "Roo.grid"
2363                                                 },
2364                                                 {
2365                                                     "*prop": "colModel[]",
2366                                                     "align": "right",
2367                                                     "dataIndex": "cobmisc_freight",
2368                                                     "header": "Shipping",
2369                                                     "width": 75,
2370                                                     "xtype": "ColumnModel",
2371                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2)  : ''); }",
2372                                                     "|xns": "Roo.grid"
2373                                                 },
2374                                                 {
2375                                                     "*prop": "colModel[]",
2376                                                     "align": "right",
2377                                                     "dataIndex": "cobmisc_tax",
2378                                                     "header": "Tax",
2379                                                     "width": 75,
2380                                                     "xtype": "ColumnModel",
2381                                                     "|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 }",
2382                                                     "|xns": "Roo.grid"
2383                                                 },
2384                                                 {
2385                                                     "*prop": "colModel[]",
2386                                                     "align": "right",
2387                                                     "dataIndex": "cobmisc_cohead_id_cohead_pretax_discount",
2388                                                     "header": "Discount (Pretax)",
2389                                                     "width": 100,
2390                                                     "xtype": "ColumnModel",
2391                                                     "|renderer": "function(v) { return String.format('{0}', v ? (1.0*v).toFixed(2) : 0); }",
2392                                                     "|xns": "Roo.grid"
2393                                                 },
2394                                                 {
2395                                                     "*prop": "colModel[]",
2396                                                     "align": "right",
2397                                                     "dataIndex": "cobmisc_misc",
2398                                                     "header": "Discount (Posttax)",
2399                                                     "width": 100,
2400                                                     "xtype": "ColumnModel",
2401                                                     "|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}",
2402                                                     "|xns": "Roo.grid"
2403                                                 },
2404                                                 {
2405                                                     "*prop": "colModel[]",
2406                                                     "align": "right",
2407                                                     "dataIndex": "cobmisc_total",
2408                                                     "header": "Total ",
2409                                                     "width": 75,
2410                                                     "xtype": "ColumnModel",
2411                                                     "|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}",
2412                                                     "|xns": "Roo.grid"
2413                                                 },
2414                                                 {
2415                                                     "*prop": "colModel[]",
2416                                                     "align": "right",
2417                                                     "dataIndex": "cobmisc_outstanding",
2418                                                     "header": "Outstanding",
2419                                                     "width": 75,
2420                                                     "xtype": "ColumnModel",
2421                                                     "|renderer": "function(v,x,r) \n{ \n    \n    return String.format('{0}', v ? (v * 1.0).toFixed(2) : 0 );\n}",
2422                                                     "|xns": "Roo.grid"
2423                                                 }
2424                                             ]
2425                                         }
2426                                     ]
2427                                 }
2428                             ]
2429                         }
2430                     ]
2431                 },
2432                 {
2433                     "listeners": {
2434                         "|activate": "function() {\n    _this.hpanel = this;\n    if (_this.hgrid) {\n        _this.hgrid.footer.onClick('first');\n    }\n}"
2435                     },
2436                     ".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\"}",
2437                     "background": true,
2438                     "fitContainer": true,
2439                     "fitToframe": true,
2440                     "region": "center",
2441                     "tableName": "events",
2442                     "title": "History",
2443                     "xtype": "GridPanel",
2444                     "|xns": "Roo",
2445                     "items": [
2446                         {
2447                             "listeners": {
2448                                 "|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}",
2449                                 "|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"
2450                             },
2451                             "*prop": "grid",
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                             "autoExpandColumn": "remarks",
2454                             "loadMask": true,
2455                             "xtype": "Grid",
2456                             "|xns": "Roo.grid",
2457                             "items": [
2458                                 {
2459                                     "listeners": {
2460                                         "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}"
2461                                     },
2462                                     "*prop": "dataSource",
2463                                     ".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\"}",
2464                                     "remoteSort": true,
2465                                     "xtype": "Store",
2466                                     "|sortInfo": "{ field : 'event_when', direction: 'DESC' }",
2467                                     "|xns": "Roo.data",
2468                                     "items": [
2469                                         {
2470                                             "*prop": "proxy",
2471                                             "xtype": "HttpProxy",
2472                                             "method": "GET",
2473                                             "|url": "baseURL + '/Roo/events.php'",
2474                                             "|xns": "Roo.data"
2475                                         },
2476                                         {
2477                                             "*prop": "reader",
2478                                             ".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\"}",
2479                                             "id": "id",
2480                                             "root": "data",
2481                                             "totalProperty": "total",
2482                                             "xtype": "JsonReader",
2483                                             "|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]",
2484                                             "|xns": "Roo.data"
2485                                         }
2486                                     ]
2487                                 },
2488                                 {
2489                                     "*prop": "footer",
2490                                     "xtype": "PagingToolbar",
2491                                     "pageSize": 25,
2492                                     "displayInfo": true,
2493                                     "displayMsg": "Displaying events{0} - {1} of {2}",
2494                                     "emptyMsg": "No events found",
2495                                     "|xns": "Roo"
2496                                 },
2497                                 {
2498                                     "*prop": "colModel[]",
2499                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"event_when\",\"columnshort\":\"event_when\",\"ctype\":\"timestamp\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2500                                     "dataIndex": "event_when",
2501                                     "header": "Changed",
2502                                     "width": 120,
2503                                     "xtype": "ColumnModel",
2504                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); }",
2505                                     "|xns": "Roo.grid"
2506                                 },
2507                                 {
2508                                     "*prop": "colModel[]",
2509                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"action\",\"columnshort\":\"action\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2510                                     "dataIndex": "action",
2511                                     "header": "action",
2512                                     "width": 120,
2513                                     "xtype": "ColumnModel",
2514                                     "|renderer": "function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); }",
2515                                     "|xns": "Roo.grid"
2516                                 },
2517                                 {
2518                                     "*prop": "colModel[]",
2519                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"ipaddr\",\"columnshort\":\"ipaddr\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2520                                     "dataIndex": "ipaddr",
2521                                     "header": "IP address",
2522                                     "width": 120,
2523                                     "xtype": "ColumnModel",
2524                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2525                                     "|xns": "Roo.grid"
2526                                 },
2527                                 {
2528                                     "*prop": "colModel[]",
2529                                     ".builderCfg": "{\"table\":\"person\",\"column\":\"person_id_name\",\"columnshort\":\"name\",\"ctype\":\"varchar\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}",
2530                                     "dataIndex": "person_id_name",
2531                                     "header": "Who",
2532                                     "width": 120,
2533                                     "xtype": "ColumnModel",
2534                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2535                                     "|xns": "Roo.grid"
2536                                 },
2537                                 {
2538                                     "*prop": "colModel[]",
2539                                     ".builderCfg": "{\"table\":\"events\",\"column\":\"remarks\",\"columnshort\":\"remarks\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":1,\"title\":\"\"}",
2540                                     "dataIndex": "remarks",
2541                                     "header": "Notes",
2542                                     "width": 200,
2543                                     "xtype": "ColumnModel",
2544                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2545                                     "|xns": "Roo.grid"
2546                                 }
2547                             ]
2548                         }
2549                     ]
2550                 },
2551                 {
2552                     "region": "center",
2553                     "title": "Stock Tx",
2554                     "xtype": "NestedLayoutPanel",
2555                     "|xns": "Roo",
2556                     "items": [
2557                         {
2558                             "|xns": "Roo",
2559                             "xtype": "BorderLayout",
2560                             "*prop": "layout",
2561                             "items": [
2562                                 {
2563                                     "|xns": "Roo",
2564                                     "xtype": "LayoutRegion",
2565                                     "*prop": "center"
2566                                 },
2567                                 {
2568                                     "*prop": "east",
2569                                     "split": true,
2570                                     "width": 500,
2571                                     "xtype": "LayoutRegion",
2572                                     "|xns": "Roo"
2573                                 },
2574                                 {
2575                                     "listeners": {
2576                                         "|activate": "function() {\n    _this.txpanel = this;\n    if (_this.txgrid) {\n        _this.txgrid.footer.onClick('first');\n    }\n}"
2577                                     },
2578                                     "background": false,
2579                                     "fitContainer": true,
2580                                     "fitToframe": true,
2581                                     "region": "center",
2582                                     "tableName": "invdetail",
2583                                     "title": "invdetail",
2584                                     "xtype": "GridPanel",
2585                                     "|xns": "Roo",
2586                                     "items": [
2587                                         {
2588                                             "listeners": {
2589                                                 "|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}"
2590                                             },
2591                                             "*prop": "grid",
2592                                             "autoExpandColumn": "item_number",
2593                                             "loadMask": true,
2594                                             "xtype": "Grid",
2595                                             "|xns": "Roo.grid",
2596                                             "items": [
2597                                                 {
2598                                                     "|xns": "Roo",
2599                                                     "xtype": "Toolbar",
2600                                                     "*prop": "toolbar",
2601                                                     "items": [
2602                                                         {
2603                                                             "listeners": {
2604                                                                 "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}"
2605                                                             },
2606                                                             "text": "Run Apply Fifo on order",
2607                                                             "xtype": "Button",
2608                                                             "|xns": "Roo.Toolbar"
2609                                                         },
2610                                                         {
2611                                                             "listeners": {
2612                                                                 "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}"
2613                                                             },
2614                                                             "text": "Run Void flagger",
2615                                                             "xtype": "Button",
2616                                                             "|xns": "Roo.Toolbar"
2617                                                         },
2618                                                         {
2619                                                             "listeners": {
2620                                                                 "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}"
2621                                                             },
2622                                                             "text": "Auto Reverse",
2623                                                             "xtype": "Button",
2624                                                             "|xns": "Roo.Toolbar"
2625                                                         }
2626                                                     ]
2627                                                 },
2628                                                 {
2629                                                     "listeners": {
2630                                                         "selectionchange": "function (_self)\n{\n    _this.txdgrid.footer.onClick('first');;\n}"
2631                                                     },
2632                                                     "*prop": "sm",
2633                                                     "singleSelect": true,
2634                                                     "xtype": "RowSelectionModel",
2635                                                     "|xns": "Roo.grid"
2636                                                 },
2637                                                 {
2638                                                     "listeners": {
2639                                                         "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}"
2640                                                     },
2641                                                     "*prop": "dataSource",
2642                                                     "remoteSort": true,
2643                                                     "xtype": "Store",
2644                                                     "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
2645                                                     "|xns": "Roo.data",
2646                                                     "items": [
2647                                                         {
2648                                                             "*prop": "proxy",
2649                                                             "method": "GET",
2650                                                             "xtype": "HttpProxy",
2651                                                             "|url": "baseURL + '/Roo/invdetail.php'",
2652                                                             "|xns": "Roo.data"
2653                                                         },
2654                                                         {
2655                                                             "|xns": "Roo.data",
2656                                                             "xtype": "JsonReader",
2657                                                             "totalProperty": "total",
2658                                                             "root": "data",
2659                                                             "*prop": "reader",
2660                                                             "id": "id",
2661                                                             "|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]"
2662                                                         }
2663                                                     ]
2664                                                 },
2665                                                 {
2666                                                     "*prop": "footer",
2667                                                     "displayInfo": true,
2668                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
2669                                                     "emptyMsg": "No invdetail found",
2670                                                     "pageSize": 9999,
2671                                                     "xtype": "PagingToolbar",
2672                                                     "|xns": "Roo"
2673                                                 },
2674                                                 {
2675                                                     "*prop": "colModel[]",
2676                                                     "dataIndex": "item_number",
2677                                                     "header": "Item",
2678                                                     "width": 75,
2679                                                     "xtype": "ColumnModel",
2680                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2681                                                     "|xns": "Roo.grid"
2682                                                 },
2683                                                 {
2684                                                     "*prop": "colModel[]",
2685                                                     "align": "right",
2686                                                     "dataIndex": "rec_shipped",
2687                                                     "header": "#Ship",
2688                                                     "width": 50,
2689                                                     "xtype": "ColumnModel",
2690                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2691                                                     "|xns": "Roo.grid"
2692                                                 },
2693                                                 {
2694                                                     "*prop": "colModel[]",
2695                                                     "align": "right",
2696                                                     "dataIndex": "rec_returned",
2697                                                     "header": "#Ret",
2698                                                     "width": 50,
2699                                                     "xtype": "ColumnModel",
2700                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2701                                                     "|xns": "Roo.grid"
2702                                                 },
2703                                                 {
2704                                                     "*prop": "colModel[]",
2705                                                     "align": "right",
2706                                                     "dataIndex": "tx_shipped",
2707                                                     "header": "#TX ship",
2708                                                     "width": 50,
2709                                                     "xtype": "ColumnModel",
2710                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2711                                                     "|xns": "Roo.grid"
2712                                                 },
2713                                                 {
2714                                                     "*prop": "colModel[]",
2715                                                     "align": "right",
2716                                                     "dataIndex": "tx_returned",
2717                                                     "header": "#TX ret",
2718                                                     "width": 50,
2719                                                     "xtype": "ColumnModel",
2720                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,0)); }",
2721                                                     "|xns": "Roo.grid"
2722                                                 },
2723                                                 {
2724                                                     "*prop": "colModel[]",
2725                                                     "align": "right",
2726                                                     "dataIndex": "tx_total",
2727                                                     "header": "#TX Tot",
2728                                                     "width": 50,
2729                                                     "xtype": "ColumnModel",
2730                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,0)); }",
2731                                                     "|xns": "Roo.grid"
2732                                                 },
2733                                                 {
2734                                                     "*prop": "colModel[]",
2735                                                     "align": "right",
2736                                                     "dataIndex": "total_value",
2737                                                     "header": "Value",
2738                                                     "width": 50,
2739                                                     "xtype": "ColumnModel",
2740                                                     "|renderer": "function(v,x,r) { \n\n    return (v*1).toFixed(3);\n}",
2741                                                     "|xns": "Roo.grid"
2742                                                 },
2743                                                 {
2744                                                     "*prop": "colModel[]",
2745                                                     "align": "right",
2746                                                     "dataIndex": "tx_total",
2747                                                     "header": "#Diff",
2748                                                     "width": 50,
2749                                                     "xtype": "ColumnModel",
2750                                                     "|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    }",
2751                                                     "|xns": "Roo.grid"
2752                                                 }
2753                                             ]
2754                                         }
2755                                     ]
2756                                 },
2757                                 {
2758                                     "listeners": {
2759                                         "|activate": "function() {\n    _this.txdpanel = this;\n    if (_this.txdgrid) {\n        _this.txdgrid.footer.onClick('first');\n    }\n}"
2760                                     },
2761                                     "background": false,
2762                                     "fitContainer": true,
2763                                     "fitToframe": true,
2764                                     "region": "east",
2765                                     "tableName": "invdetail",
2766                                     "title": "invdetail",
2767                                     "xtype": "GridPanel",
2768                                     "|xns": "Roo",
2769                                     "items": [
2770                                         {
2771                                             "listeners": {
2772                                                 "|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}",
2773                                                 "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}"
2774                                             },
2775                                             "*prop": "grid",
2776                                             "autoExpandColumn": "invhist_comments",
2777                                             "loadMask": true,
2778                                             "xtype": "Grid",
2779                                             "|xns": "Roo.grid",
2780                                             "items": [
2781                                                 {
2782                                                     "|xns": "Roo",
2783                                                     "xtype": "Toolbar",
2784                                                     "*prop": "toolbar",
2785                                                     "items": [
2786                                                         {
2787                                                             "listeners": {
2788                                                                 "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}"
2789                                                             },
2790                                                             "text": "Duplicate Selected",
2791                                                             "xtype": "Button",
2792                                                             "|xns": "Roo.Toolbar"
2793                                                         },
2794                                                         {
2795                                                             "|xns": "Roo.Toolbar",
2796                                                             "xtype": "Fill"
2797                                                         },
2798                                                         {
2799                                                             "text": "Issue Date",
2800                                                             "xtype": "TextItem",
2801                                                             "|xns": "Roo.Toolbar"
2802                                                         },
2803                                                         {
2804                                                             "listeners": {
2805                                                                 "render": "function (_self)\n{\n    _this.dateSel = _self;\n}"
2806                                                             },
2807                                                             "allowBlank": false,
2808                                                             "fieldLabel": "Issue Date",
2809                                                             "format": "Y-m-d",
2810                                                             "name": "issue_date",
2811                                                             "width": 150,
2812                                                             "xtype": "DateField",
2813                                                             "|xns": "Roo.form"
2814                                                         },
2815                                                         {
2816                                                             "listeners": {
2817                                                                 "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}"
2818                                                             },
2819                                                             "text": "Reverse Selected",
2820                                                             "xtype": "Button",
2821                                                             "|xns": "Roo.Toolbar"
2822                                                         }
2823                                                     ]
2824                                                 },
2825                                                 {
2826                                                     "listeners": {
2827                                                         "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}"
2828                                                     },
2829                                                     "*prop": "dataSource",
2830                                                     "remoteSort": true,
2831                                                     "xtype": "Store",
2832                                                     "|sortInfo": "{ field : 'invdetail_id', direction: 'ASC' }",
2833                                                     "|xns": "Roo.data",
2834                                                     "items": [
2835                                                         {
2836                                                             "*prop": "proxy",
2837                                                             "method": "GET",
2838                                                             "xtype": "HttpProxy",
2839                                                             "|url": "baseURL + '/Roo/invdetail.php'",
2840                                                             "|xns": "Roo.data"
2841                                                         },
2842                                                         {
2843                                                             "|xns": "Roo.data",
2844                                                             "xtype": "JsonReader",
2845                                                             "totalProperty": "total",
2846                                                             "root": "data",
2847                                                             "*prop": "reader",
2848                                                             "id": "id",
2849                                                             "|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]"
2850                                                         }
2851                                                     ]
2852                                                 },
2853                                                 {
2854                                                     "*prop": "footer",
2855                                                     "displayInfo": true,
2856                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
2857                                                     "emptyMsg": "No invdetail found",
2858                                                     "pageSize": 9999,
2859                                                     "xtype": "PagingToolbar",
2860                                                     "|xns": "Roo"
2861                                                 },
2862                                                 {
2863                                                     "*prop": "colModel[]",
2864                                                     "dataIndex": "invdetail_id",
2865                                                     "header": "TX#",
2866                                                     "width": 60,
2867                                                     "xtype": "ColumnModel",
2868                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2869                                                     "|xns": "Roo.grid"
2870                                                 },
2871                                                 {
2872                                                     "*prop": "colModel[]",
2873                                                     "dataIndex": "invhist_transdate",
2874                                                     "header": "Date",
2875                                                     "width": 75,
2876                                                     "xtype": "ColumnModel",
2877                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2878                                                     "|xns": "Roo.grid"
2879                                                 },
2880                                                 {
2881                                                     "*prop": "colModel[]",
2882                                                     "dataIndex": "invhist_ordnumber",
2883                                                     "header": "Ref#",
2884                                                     "width": 75,
2885                                                     "xtype": "ColumnModel",
2886                                                     "|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 }",
2887                                                     "|xns": "Roo.grid"
2888                                                 },
2889                                                 {
2890                                                     "*prop": "colModel[]",
2891                                                     "dataIndex": "location_name",
2892                                                     "header": "TX#",
2893                                                     "width": 60,
2894                                                     "xtype": "ColumnModel",
2895                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2896                                                     "|xns": "Roo.grid"
2897                                                 },
2898                                                 {
2899                                                     "*prop": "colModel[]",
2900                                                     "dataIndex": "invhist_comments",
2901                                                     "header": "Notes",
2902                                                     "width": 75,
2903                                                     "xtype": "ColumnModel",
2904                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
2905                                                     "|xns": "Roo.grid"
2906                                                 },
2907                                                 {
2908                                                     "*prop": "colModel[]",
2909                                                     "align": "right",
2910                                                     "dataIndex": "invdetail_qty",
2911                                                     "header": "Qty Changed",
2912                                                     "width": 50,
2913                                                     "xtype": "ColumnModel",
2914                                                     "|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}",
2915                                                     "|xns": "Roo.grid"
2916                                                 },
2917                                                 {
2918                                                     "*prop": "colModel[]",
2919                                                     "align": "right",
2920                                                     "dataIndex": "invhist_value_before",
2921                                                     "header": "Qty Changed",
2922                                                     "width": 75,
2923                                                     "xtype": "ColumnModel",
2924                                                     "|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}",
2925                                                     "|xns": "Roo.grid"
2926                                                 },
2927                                                 {
2928                                                     "*prop": "colModel[]",
2929                                                     "dataIndex": "invhist_posted",
2930                                                     "header": "Posted",
2931                                                     "width": 40,
2932                                                     "xtype": "ColumnModel",
2933                                                     "|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 }",
2934                                                     "|xns": "Roo.grid"
2935                                                 }
2936                                             ]
2937                                         }
2938                                     ]
2939                                 }
2940                             ]
2941                         }
2942                     ]
2943                 },
2944                 {
2945                     "region": "center",
2946                     "title": "GL Tx",
2947                     "xtype": "NestedLayoutPanel",
2948                     "|xns": "Roo",
2949                     "items": [
2950                         {
2951                             "|xns": "Roo",
2952                             "xtype": "BorderLayout",
2953                             "*prop": "layout",
2954                             "items": [
2955                                 {
2956                                     "|xns": "Roo",
2957                                     "xtype": "LayoutRegion",
2958                                     "*prop": "center"
2959                                 },
2960                                 {
2961                                     "*prop": "east",
2962                                     "split": true,
2963                                     "width": 500,
2964                                     "xtype": "LayoutRegion",
2965                                     "|xns": "Roo"
2966                                 },
2967                                 {
2968                                     "listeners": {
2969                                         "|activate": "function() {\n    _this.gltxpanel = this;\n    if (_this.gltxgrid) {\n        _this.gltxgrid.footer.onClick('first');\n    }\n}"
2970                                     },
2971                                     "background": false,
2972                                     "fitContainer": true,
2973                                     "fitToframe": true,
2974                                     "region": "center",
2975                                     "tableName": "invdetail",
2976                                     "title": "invdetail",
2977                                     "xtype": "GridPanel",
2978                                     "|xns": "Roo",
2979                                     "items": [
2980                                         {
2981                                             "listeners": {
2982                                                 "|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}",
2983                                                 "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}"
2984                                             },
2985                                             "*prop": "grid",
2986                                             "autoExpandColumn": "gltrans_accnt_id_accnt_descrip",
2987                                             "loadMask": true,
2988                                             "xtype": "Grid",
2989                                             "|xns": "Roo.grid",
2990                                             "items": [
2991                                                 {
2992                                                     "listeners": {
2993                                                         "selectionchange": "function (_self)\n{\n    _this.gltxdgrid.footer.onClick('first');;\n}"
2994                                                     },
2995                                                     "*prop": "sm",
2996                                                     "singleSelect": true,
2997                                                     "xtype": "RowSelectionModel",
2998                                                     "|xns": "Roo.grid"
2999                                                 },
3000                                                 {
3001                                                     "listeners": {
3002                                                         "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}"
3003                                                     },
3004                                                     "*prop": "dataSource",
3005                                                     "remoteSort": true,
3006                                                     "xtype": "Store",
3007                                                     "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
3008                                                     "|xns": "Roo.data",
3009                                                     "items": [
3010                                                         {
3011                                                             "*prop": "proxy",
3012                                                             "method": "GET",
3013                                                             "xtype": "HttpProxy",
3014                                                             "|url": "baseURL + '/Roo/gltrans.php'",
3015                                                             "|xns": "Roo.data"
3016                                                         },
3017                                                         {
3018                                                             "|xns": "Roo.data",
3019                                                             "xtype": "JsonReader",
3020                                                             "totalProperty": "total",
3021                                                             "root": "data",
3022                                                             "*prop": "reader",
3023                                                             "id": "id",
3024                                                             "|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]"
3025                                                         }
3026                                                     ]
3027                                                 },
3028                                                 {
3029                                                     "*prop": "footer",
3030                                                     "displayInfo": true,
3031                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
3032                                                     "emptyMsg": "No invdetail found",
3033                                                     "pageSize": 9999,
3034                                                     "xtype": "PagingToolbar",
3035                                                     "|xns": "Roo",
3036                                                     "items": [
3037                                                         {
3038                                                             "listeners": {
3039                                                                 "render": "function (_self)\n{\n    _this.glsalesbtn = _self;\n}",
3040                                                                 "click": "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
3041                                                             },
3042                                                             "enableToggle": true,
3043                                                             "pressed": true,
3044                                                             "text": "Split sales",
3045                                                             "xtype": "Button",
3046                                                             "|xns": "Roo.Toolbar"
3047                                                         }
3048                                                     ]
3049                                                 },
3050                                                 {
3051                                                     "*prop": "colModel[]",
3052                                                     "dataIndex": "gltrans_as_summary",
3053                                                     "header": "Summary",
3054                                                     "width": 50,
3055                                                     "xtype": "ColumnModel",
3056                                                     "|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 }",
3057                                                     "|xns": "Roo.grid"
3058                                                 },
3059                                                 {
3060                                                     "*prop": "colModel[]",
3061                                                     "dataIndex": "gltrans_accnt_id_accnt_descrip",
3062                                                     "header": "Account",
3063                                                     "width": 75,
3064                                                     "xtype": "ColumnModel",
3065                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3066                                                     "|xns": "Roo.grid"
3067                                                 },
3068                                                 {
3069                                                     "*prop": "colModel[]",
3070                                                     "align": "right",
3071                                                     "dataIndex": "gltrans_amount_credit",
3072                                                     "header": "Credit",
3073                                                     "width": 75,
3074                                                     "xtype": "ColumnModel",
3075                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,3)); }",
3076                                                     "|xns": "Roo.grid"
3077                                                 },
3078                                                 {
3079                                                     "*prop": "colModel[]",
3080                                                     "align": "right",
3081                                                     "dataIndex": "gltrans_amount_debit",
3082                                                     "header": "Debit",
3083                                                     "width": 75,
3084                                                     "xtype": "ColumnModel",
3085                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3086                                                     "|xns": "Roo.grid"
3087                                                 },
3088                                                 {
3089                                                     "*prop": "colModel[]",
3090                                                     "align": "right",
3091                                                     "dataIndex": "gltrans_amount_total",
3092                                                     "header": "Sum",
3093                                                     "width": 75,
3094                                                     "xtype": "ColumnModel",
3095                                                     "|renderer": "function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }",
3096                                                     "|xns": "Roo.grid"
3097                                                 },
3098                                                 {
3099                                                     "*prop": "colModel[]",
3100                                                     "align": "right",
3101                                                     "dataIndex": "gltrans_amount_total_unposted",
3102                                                     "header": "Unposted",
3103                                                     "width": 75,
3104                                                     "xtype": "ColumnModel",
3105                                                     "|renderer": "function(v) { return String.format('<span style=\"color:red\">{0}</span>', Roo.util.Format.number(v,3)); }",
3106                                                     "|xns": "Roo.grid"
3107                                                 }
3108                                             ]
3109                                         }
3110                                     ]
3111                                 },
3112                                 {
3113                                     "listeners": {
3114                                         "|activate": "function() {\n    _this.gltxdpanel = this;\n    if (_this.gltxdgrid) {\n        _this.gltxdgrid.footer.onClick('first');\n    }\n}"
3115                                     },
3116                                     "background": false,
3117                                     "fitContainer": true,
3118                                     "fitToframe": true,
3119                                     "region": "east",
3120                                     "tableName": "invdetail",
3121                                     "title": "invdetail",
3122                                     "xtype": "GridPanel",
3123                                     "|xns": "Roo",
3124                                     "items": [
3125                                         {
3126                                             "listeners": {
3127                                                 "|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}",
3128                                                 "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}"
3129                                             },
3130                                             "*prop": "grid",
3131                                             "autoExpandColumn": "gltrans_notes",
3132                                             "loadMask": true,
3133                                             "xtype": "Grid",
3134                                             "|xns": "Roo.grid",
3135                                             "items": [
3136                                                 {
3137                                                     "listeners": {
3138                                                         "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}"
3139                                                     },
3140                                                     "*prop": "dataSource",
3141                                                     "remoteSort": true,
3142                                                     "xtype": "Store",
3143                                                     "|sortInfo": "{ field : 'gltrans_docnumber', direction: 'ASC' }",
3144                                                     "|xns": "Roo.data",
3145                                                     "items": [
3146                                                         {
3147                                                             "*prop": "proxy",
3148                                                             "method": "GET",
3149                                                             "xtype": "HttpProxy",
3150                                                             "|url": "baseURL + '/Roo/gltrans.php'",
3151                                                             "|xns": "Roo.data"
3152                                                         },
3153                                                         {
3154                                                             "|xns": "Roo.data",
3155                                                             "xtype": "JsonReader",
3156                                                             "totalProperty": "total",
3157                                                             "root": "data",
3158                                                             "*prop": "reader",
3159                                                             "id": "id",
3160                                                             "|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]"
3161                                                         }
3162                                                     ]
3163                                                 },
3164                                                 {
3165                                                     "*prop": "footer",
3166                                                     "displayInfo": true,
3167                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
3168                                                     "emptyMsg": "No invdetail found",
3169                                                     "pageSize": 9999,
3170                                                     "xtype": "PagingToolbar",
3171                                                     "|xns": "Roo",
3172                                                     "items": [
3173                                                         {
3174                                                             "listeners": {
3175                                                                 "click": "function (_self, e)\n{\n    new Pman.Download( {\n        grid : _this.gltxdgrid\n    \n    });\n}"
3176                                                             },
3177                                                             "text": "Download",
3178                                                             "xtype": "Button",
3179                                                             "|xns": "Roo.Toolbar"
3180                                                         }
3181                                                     ]
3182                                                 },
3183                                                 {
3184                                                     "*prop": "colModel[]",
3185                                                     "dataIndex": "gltrans_id",
3186                                                     "header": "Ref#",
3187                                                     "sortable": true,
3188                                                     "width": 75,
3189                                                     "xtype": "ColumnModel",
3190                                                     "|renderer": "function(v) { return String.format('{0}', v ); }",
3191                                                     "|xns": "Roo.grid"
3192                                                 },
3193                                                 {
3194                                                     "*prop": "colModel[]",
3195                                                     "dataIndex": "gltrans_date",
3196                                                     "header": "Date",
3197                                                     "width": 75,
3198                                                     "xtype": "ColumnModel",
3199                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
3200                                                     "|xns": "Roo.grid"
3201                                                 },
3202                                                 {
3203                                                     "*prop": "colModel[]",
3204                                                     "dataIndex": "gltrans_docnumber",
3205                                                     "header": "Doc#",
3206                                                     "width": 75,
3207                                                     "xtype": "ColumnModel",
3208                                                     "|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}",
3209                                                     "|xns": "Roo.grid"
3210                                                 },
3211                                                 {
3212                                                     "*prop": "colModel[]",
3213                                                     "dataIndex": "gltrans_source",
3214                                                     "header": "Source",
3215                                                     "width": 50,
3216                                                     "xtype": "ColumnModel",
3217                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3218                                                     "|xns": "Roo.grid"
3219                                                 },
3220                                                 {
3221                                                     "*prop": "colModel[]",
3222                                                     "dataIndex": "gltrans_notes",
3223                                                     "header": "Notes",
3224                                                     "width": 75,
3225                                                     "xtype": "ColumnModel",
3226                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3227                                                     "|xns": "Roo.grid"
3228                                                 },
3229                                                 {
3230                                                     "*prop": "colModel[]",
3231                                                     "align": "right",
3232                                                     "dataIndex": "gltrans_amount",
3233                                                     "header": "Amount",
3234                                                     "width": 75,
3235                                                     "xtype": "ColumnModel",
3236                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
3237                                                     "|xns": "Roo.grid"
3238                                                 },
3239                                                 {
3240                                                     "*prop": "colModel[]",
3241                                                     "dataIndex": "gltrans_posted",
3242                                                     "header": "Posted",
3243                                                     "width": 50,
3244                                                     "xtype": "ColumnModel",
3245                                                     "|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 }",
3246                                                     "|xns": "Roo.grid"
3247                                                 }
3248                                             ]
3249                                         }
3250                                     ]
3251                                 }
3252                             ]
3253                         }
3254                     ]
3255                 },
3256                 {
3257                     "listeners": {
3258                         "|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}"
3259                     },
3260                     "background": true,
3261                     "fitContainer": true,
3262                     "fitToframe": true,
3263                     "region": "center",
3264                     "tableName": "coitem",
3265                     "title": "Profit",
3266                     "xtype": "GridPanel",
3267                     "|xns": "Roo",
3268                     "items": [
3269                         {
3270                             "listeners": {
3271                                 "|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}"
3272                             },
3273                             "*prop": "grid",
3274                             "autoExpandColumn": "item_number",
3275                             "loadMask": true,
3276                             "xtype": "Grid",
3277                             "|xns": "Roo.grid",
3278                             "items": [
3279                                 {
3280                                     "listeners": {
3281                                         "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}"
3282                                     },
3283                                     "*prop": "dataSource",
3284                                     "remoteSort": true,
3285                                     "xtype": "Store",
3286                                     "|sortInfo": "{ field : 'coitem_linenumber,coitem_subnumber', direction: 'ASC' }",
3287                                     "|xns": "Roo.data",
3288                                     "items": [
3289                                         {
3290                                             "*prop": "proxy",
3291                                             "method": "GET",
3292                                             "xtype": "HttpProxy",
3293                                             "|url": "baseURL + '/Roo/coitem.php'",
3294                                             "|xns": "Roo.data"
3295                                         },
3296                                         {
3297                                             "|xns": "Roo.data",
3298                                             "xtype": "JsonReader",
3299                                             "totalProperty": "total",
3300                                             "root": "data",
3301                                             "*prop": "reader",
3302                                             "id": "id",
3303                                             "|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]"
3304                                         }
3305                                     ]
3306                                 },
3307                                 {
3308                                     "*prop": "footer",
3309                                     "displayInfo": true,
3310                                     "displayMsg": "Displaying coitem{0} - {1} of {2}",
3311                                     "emptyMsg": "No coitem found",
3312                                     "pageSize": 25,
3313                                     "xtype": "PagingToolbar",
3314                                     "|xns": "Roo"
3315                                 },
3316                                 {
3317                                     "*prop": "colModel[]",
3318                                     "dataIndex": "item_number",
3319                                     "header": "Item Code",
3320                                     "width": 75,
3321                                     "xtype": "ColumnModel",
3322                                     "|renderer": "function(v) { return String.format('{0}', v); }",
3323                                     "|xns": "Roo.grid"
3324                                 },
3325                                 {
3326                                     "*prop": "colModel[]",
3327                                     "dataIndex": "calc_subtotal",
3328                                     "header": "SubTotal",
3329                                     "width": 200,
3330                                     "xtype": "ColumnModel",
3331                                     "|renderer": "function(v) {\n\n\n     return Roo.util.Format.number( v, 2);\n  }",
3332                                     "|xns": "Roo.grid"
3333                                 },
3334                                 {
3335                                     "*prop": "colModel[]",
3336                                     "dataIndex": "calc_cost_total",
3337                                     "header": "Cost of goods",
3338                                     "width": 200,
3339                                     "xtype": "ColumnModel",
3340                                     "|renderer": "function(v) {\n\n    return Roo.util.Format.number( v, 2);\n  }",
3341                                     "|xns": "Roo.grid"
3342                                 },
3343                                 {
3344                                     "*prop": "colModel[]",
3345                                     "dataIndex": "profit",
3346                                     "header": "Profit",
3347                                     "width": 200,
3348                                     "xtype": "ColumnModel",
3349                                     "|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}",
3350                                     "|xns": "Roo.grid"
3351                                 }
3352                             ]
3353                         }
3354                     ]
3355                 },
3356                 {
3357                     "listeners": {
3358                         "click": "function (_self, e)\n{\n      if (_this.grid)  _this.grid.stopEditing();\n    _this.dialog.hide();\n}"
3359                     },
3360                     "*prop": "buttons[]",
3361                     "text": "Cancel",
3362                     "xtype": "Button",
3363                     "|xns": "Roo"
3364                 },
3365                 {
3366                     "listeners": {
3367                         "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}",
3368                         "render": "function (_self)\n{\n    _this.saveBtn = _self;\n}"
3369                     },
3370                     "*prop": "buttons[]",
3371                     "text": "Save",
3372                     "xtype": "Button",
3373                     "|xns": "Roo"
3374                 }
3375             ]
3376         }
3377     ],
3378     "permname": "",
3379     "modOrder": "001"
3380 }