Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtuplePurchaseOrder.bjs
1 {
2     "id": "roo-file-21",
3     "name": "Pman.Dialog.XtuplePurchaseOrder",
4     "parent": "",
5     "title": "",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtuplePurchaseOrder.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "show": "function () \n{\n       this.layout.getRegion('center').showPanel(0);\n}"
11             },
12             "closable": false,
13             "collapsible": false,
14             "height": 550,
15             "modal": true,
16             "resizable": true,
17             "title": "New Purchase Order",
18             "width": 900,
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 hid = _this.form.findField('pohead_id').getValue();\n\n    if(!hid.length){\n        Roo.MessageBox.alert(\"Error\", \"Please save your purchase order first\"); \n        return false;\n    }\n\n    \n    if (!_this.grid) {\n        _dialog.layout.showPanel(1);\n        doit.defer(500);\n        return;\n    }\n    \n    \n    \n    var doit = function () { \n        new Pman.Download({\n            grid : _this.grid\n        });\n    }\n    doit();\n            \n   \n}"
41                                     },
42                                     "cls": "x-btn-text-icon",
43                                     "text": "Download Purchase Order Items (Excel)",
44                                     "xtype": "Button",
45                                     "|icon": "rootURL + '/Pman/templates/images/save.gif'",
46                                     "|xns": "Roo.Toolbar"
47                                 },
48                                 {
49                                     "listeners": {
50                                         "render": "function (_self)\n{\n    _this.uploadBtn = _self;\n}"
51                                     },
52                                     "text": "Upload Purchase Order",
53                                     "xtype": "Button",
54                                     "|xns": "Roo.Toolbar",
55                                     "items": [
56                                         {
57                                             "|xns": "Roo.menu",
58                                             "xtype": "Menu",
59                                             "*prop": "menu",
60                                             "items": [
61                                                 {
62                                                     "listeners": {
63                                                         "click": "function (_self, e)\n{\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        Roo.MessageBox.alert(\"Error\", \"Please save your purchase order first\"); \n        return false;\n    }\n    Pman.Dialog.Image.show(\n       {\n            timeout : 60000,\n            _url : baseURL+'/Xtuple/Import/PurchaseOrder?' + Roo.urlEncode({'pohead_id' : hid})\n        \n       },\n       function () {\n            if(_this.grid){\n                _this.grid.footer.onClick('first');\n            }\n            Roo.MessageBox.alert(\"Notice\", 'UPLOADED');\n       }\n   );\n}"
64                                                     },
65                                                     "text": "Upload Standard Excel",
66                                                     "xtype": "Item",
67                                                     "|xns": "Roo.menu"
68                                                 },
69                                                 {
70                                                     "listeners": {
71                                                         "click": "function (_self, e)\n{\n\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        Roo.MessageBox.alert(\"Error\", \"Please save your purchase order first\"); \n        return false;\n    }\n    \n   Pman.Dialog.Image.show(\n   {\n        _url : baseURL+'/Xtuple/Import/AUPurchaseOrder?' + Roo.urlEncode({'pohead_id' :hid})\n        \n   },\n   function (data) {\n       if(_this.grid){\n            _this.grid.footer.onClick('first');\n       }\n       Roo.MessageBox.alert(\"Notice\", 'IMPORTED');\n\n   });\n}"
72                                                     },
73                                                     "text": "Upload AU Import Excel",
74                                                     "xtype": "Item",
75                                                     "|xns": "Roo.menu"
76                                                 }
77                                             ]
78                                         }
79                                     ]
80                                 }
81                             ]
82                         }
83                     ]
84                 },
85                 {
86                     "region": "center",
87                     "title": "Order Details",
88                     "xtype": "ContentPanel",
89                     "|xns": "Roo",
90                     "items": [
91                         {
92                             "listeners": {
93                                 "|actioncomplete": "function(_self,action)\n{\n    if (action.type == 'setdata') {\n        _this.uploadBtn.disabled = false;\n        if(!_this.data.pohead_id && Pman.Login.authUser.name.length){\n            _this.saveBtn.show();\n            _this.form.findField('pohead_agent_username').setValue(Pman.Login.authUser.name);\n            _this.form.findField('pohead_orderdate').setValue(new Date());\n            _this.form.findField('pohead_bg_arrival_est_day').setValue(new Date());\n            _this.form.findField('pohead_bg_available_est_day').setValue(new Date());\n            _this.form.findField('pohead_bg_available_latest_day').setValue(new Date());\n            return;\n        }\n        _this.dialog.setTitle(\"Edit Purchase Order\");\n        var params = {\n            '_id' : _this.data.pohead_id\n        }\n        if(_this.data.office){\n            params['_roo_office'] = _this.data.office;\n        }\n        \n        this.load({ method: 'GET', params: params});\n        return;\n    }\n    if (action.type == 'load') {\n         _this.dontClose = false;\n        if(_this.data.office){\n            _this.uploadBtn.disabled = true;\n        }\n        _this.saveBtn.hide();\n        if (action.result.data.pohead_status == 'U') {\n            _this.saveBtn.show();\n        }\n        var cn = _this.form.findField('pohead_curr_id');\n        cn.setDisabled(true);\n        if (action.result.data.pohead_id * 1 < 1) {\n            cn.setDisabled(false);\n        }\n        \n        if(_this.grid){\n            _this.grid.footer.onClick('first');\n        }\n        \n        return;\n    }\n    if (action.type =='submit') {\n    \n\n        var cid = this.findField('pohead_id').getValue()*1;\n        if (cid && !_this.dontClose) {\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         Roo.log(action);\n         _this.dontClose = false;\n         _this.data.pohead_id = action.result.data.pohead_id;\n         this.fireEvent('actioncomplete', this,   { \n                type: 'setdata', \n                data: { \n                    pohead_id : action.result.data.pohead_id\n                 } \n         });\n\n         \n    }\n}\n",
94                                 "|rendered": "function (form)\n{\n    _this.form= form;\n}\n",
95                                 "actionfailed": "function (_self, action)\n{\n    _this.dialog.el.unmask();\n    if (action.failureType == 'client') {\n        Roo.MessageBox.alert(\"Error\", \"Please fill in all the required fields\");\n    }\n    if (action.failureType == 'server') {\n        Roo.MessageBox.alert(\"Error\", action.result.errorMsg);\n    }\n    _this.dialog.layout.getRegion('center').showPanel(0);\n\n}"
96                             },
97                             "labelWidth": 200,
98                             "method": "POST",
99                             "style": "margin:10px;",
100                             "xtype": "Form",
101                             "|url": "baseURL + '/Xtuple/Roo/Pohead.php'",
102                             "|xns": "Roo.form",
103                             "items": [
104                                 {
105                                     "emptyText": "Automatic",
106                                     "fieldLabel": "Order #",
107                                     "name": "pohead_number",
108                                     "readOnly": true,
109                                     "width": 150,
110                                     "xtype": "TextField",
111                                     "|xns": "Roo.form"
112                                 },
113                                 {
114                                     "allowBlank": false,
115                                     "fieldLabel": "Order Date",
116                                     "format": "Y-m-d",
117                                     "name": "pohead_orderdate",
118                                     "width": 150,
119                                     "xtype": "DateField",
120                                     "|xns": "Roo.form"
121                                 },
122                                 {
123                                     "fieldLabel": "Estimated Arrival Date",
124                                     "format": "Y-m-d",
125                                     "name": "pohead_bg_arrival_est_day",
126                                     "width": 150,
127                                     "xtype": "DateField",
128                                     "|xns": "Roo.form"
129                                 },
130                                 {
131                                     "fieldLabel": "Estimated Available Date",
132                                     "format": "Y-m-d",
133                                     "name": "pohead_bg_available_est_day",
134                                     "width": 150,
135                                     "xtype": "DateField",
136                                     "|xns": "Roo.form"
137                                 },
138                                 {
139                                     "fieldLabel": "Latest Estimated Available Date",
140                                     "format": "Y-m-d",
141                                     "name": "pohead_bg_available_latest_day",
142                                     "width": 150,
143                                     "xtype": "DateField",
144                                     "|xns": "Roo.form"
145                                 },
146                                 {
147                                     "fieldLabel": "VA",
148                                     "name": "pohead_bg_va",
149                                     "width": 150,
150                                     "xtype": "TextField",
151                                     "|xns": "Roo.form"
152                                 },
153                                 {
154                                     "fieldLabel": "Vendor",
155                                     "name": "pohead_vend_id_vend_name",
156                                     "readOnly": true,
157                                     "width": 250,
158                                     "xtype": "TextField",
159                                     "|xns": "Roo.form"
160                                 },
161                                 {
162                                     "allowBlank": false,
163                                     "displayField": "fname",
164                                     "editable": false,
165                                     "fieldLabel": "Status",
166                                     "hiddenName": "pohead_status",
167                                     "listWidth": 200,
168                                     "mode": "local",
169                                     "name": "pohead_status",
170                                     "readOnly": true,
171                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{fname}</b> </div>",
172                                     "triggerAction": "all",
173                                     "value": "U",
174                                     "valueField": "ftype",
175                                     "width": 250,
176                                     "xtype": "ComboBox",
177                                     "|xns": "Roo.form",
178                                     "items": [
179                                         {
180                                             "*prop": "store",
181                                             "xtype": "SimpleStore",
182                                             "|data": "[ \n    [ 'U', \"Unreleased\"],\n    [ 'O', \"Open\"],\n    [ 'C' , \"Closed\"]\n]\n",
183                                             "|fields": "[  'ftype', 'fname']",
184                                             "|xns": "Roo.data"
185                                         }
186                                     ]
187                                 },
188                                 {
189                                     "allowBlank": false,
190                                     "displayField": "curr_name",
191                                     "editable": false,
192                                     "emptyText": "Select Currency",
193                                     "fieldLabel": "Currency",
194                                     "forceSelection": true,
195                                     "hiddenName": "pohead_curr_id",
196                                     "listWidth": 400,
197                                     "loadingText": "Searching...",
198                                     "minChars": 2,
199                                     "name": "pohead_curr_id_curr_name",
200                                     "pageSize": 20,
201                                     "qtip": "Select Currency",
202                                     "queryParam": "query[curr_name]",
203                                     "selectOnFocus": true,
204                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{curr_name}</b> </div>",
205                                     "triggerAction": "all",
206                                     "typeAhead": true,
207                                     "valueField": "curr_id",
208                                     "width": 250,
209                                     "xtype": "ComboBox",
210                                     "|xns": "Roo.form",
211                                     "items": [
212                                         {
213                                             "listeners": {
214                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n}\n"
215                                             },
216                                             "*prop": "store",
217                                             "remoteSort": true,
218                                             "xtype": "Store",
219                                             "|sortInfo": "{ direction : 'ASC', field: 'curr_id' }",
220                                             "|xns": "Roo.data",
221                                             "items": [
222                                                 {
223                                                     "*prop": "proxy",
224                                                     "xtype": "HttpProxy",
225                                                     "method": "GET",
226                                                     "|xns": "Roo.data",
227                                                     "|url": "baseURL + '/Roo/curr_symbol.php'"
228                                                 },
229                                                 {
230                                                     "*prop": "reader",
231                                                     "id": "curr_id",
232                                                     "root": "data",
233                                                     "totalProperty": "total",
234                                                     "xtype": "JsonReader",
235                                                     "|fields": "[\n    {\"name\":\"curr_id\",\"type\":\"int\"},\n    {\"name\":\"curr_name\",\"type\":\"string\"}\n]",
236                                                     "|xns": "Roo.data"
237                                                 }
238                                             ]
239                                         }
240                                     ]
241                                 },
242                                 {
243                                     "allowBlank": false,
244                                     "displayField": "location_name",
245                                     "editable": true,
246                                     "emptyText": "Select a location",
247                                     "fieldLabel": "Location",
248                                     "forceSelection": true,
249                                     "hiddenName": "pohead_location_id",
250                                     "listWidth": 400,
251                                     "loadingText": "Searching...",
252                                     "minChars": 2,
253                                     "name": "pohead_location_id_location_name",
254                                     "pageSize": 200,
255                                     "qtip": "Select terms",
256                                     "queryParam": "query[location_name]",
257                                     "selectOnFocus": true,
258                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{location_name}</b> </div>",
259                                     "triggerAction": "all",
260                                     "typeAhead": false,
261                                     "valueField": "location_id",
262                                     "width": 250,
263                                     "xtype": "ComboBox",
264                                     "|xns": "Roo.form",
265                                     "items": [
266                                         {
267                                             "listeners": {
268                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n     o.params.location_netable = 1;\n     o.params._viewType = 'local';\n}\n"
269                                             },
270                                             "*prop": "store",
271                                             "remoteSort": true,
272                                             "xtype": "Store",
273                                             "|sortInfo": "{ direction : 'ASC', field: 'location_name' }",
274                                             "|xns": "Roo.data",
275                                             "items": [
276                                                 {
277                                                     "*prop": "proxy",
278                                                     "method": "GET",
279                                                     "xtype": "HttpProxy",
280                                                     "|url": "baseURL + '/Roo/location.php'",
281                                                     "|xns": "Roo.data"
282                                                 },
283                                                 {
284                                                     "*prop": "reader",
285                                                     "id": "location_id",
286                                                     "root": "data",
287                                                     "totalProperty": "total",
288                                                     "xtype": "JsonReader",
289                                                     "|fields": "[{\"name\":\"location_id\",\"type\":\"int\"},\"location_name\"]",
290                                                     "|xns": "Roo.data"
291                                                 }
292                                             ]
293                                         }
294                                     ]
295                                 },
296                                 {
297                                     "allowBlank": false,
298                                     "displayField": "terms_descrip",
299                                     "editable": false,
300                                     "emptyText": "Select Terms",
301                                     "fieldLabel": "Terms",
302                                     "forceSelection": true,
303                                     "hiddenName": "pohead_terms_id",
304                                     "listWidth": 400,
305                                     "loadingText": "Searching...",
306                                     "minChars": 2,
307                                     "name": "pohead_terms_id_terms_descrip",
308                                     "pageSize": 20,
309                                     "qtip": "Select Terms",
310                                     "queryParam": "query[terms_descrip]",
311                                     "selectOnFocus": true,
312                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{terms_descrip}</b> </div>",
313                                     "triggerAction": "all",
314                                     "typeAhead": true,
315                                     "valueField": "terms_id",
316                                     "width": 250,
317                                     "xtype": "ComboBox",
318                                     "|xns": "Roo.form",
319                                     "items": [
320                                         {
321                                             "listeners": {
322                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n}\n"
323                                             },
324                                             "*prop": "store",
325                                             "remoteSort": true,
326                                             "xtype": "Store",
327                                             "|sortInfo": "{ direction : 'ASC', field: 'terms_descrip' }",
328                                             "|xns": "Roo.data",
329                                             "items": [
330                                                 {
331                                                     "*prop": "proxy",
332                                                     "method": "GET",
333                                                     "xtype": "HttpProxy",
334                                                     "|url": "baseURL + '/Roo/Terms.php'",
335                                                     "|xns": "Roo.data"
336                                                 },
337                                                 {
338                                                     "*prop": "reader",
339                                                     "id": "terms_id",
340                                                     "root": "data",
341                                                     "totalProperty": "total",
342                                                     "xtype": "JsonReader",
343                                                     "|fields": "[\n    {\"name\":\"terms_id\",\"type\":\"int\"},\n    {\"name\":\"terms_descrip\",\"type\":\"string\"}\n]",
344                                                     "|xns": "Roo.data"
345                                                 }
346                                             ]
347                                         }
348                                     ]
349                                 },
350                                 {
351                                     "allowBlank": false,
352                                     "displayField": "taxzone_descrip",
353                                     "editable": false,
354                                     "emptyText": "Select Tax Zone",
355                                     "fieldLabel": "Tax Zone",
356                                     "forceSelection": true,
357                                     "hiddenName": "pohead_taxzone_id",
358                                     "listWidth": 400,
359                                     "loadingText": "Searching...",
360                                     "minChars": 2,
361                                     "name": "pohead_taxzone_id_taxzone_descrip",
362                                     "pageSize": 20,
363                                     "qtip": "Select Tax Zone",
364                                     "queryParam": "query[taxzone_descrip]",
365                                     "selectOnFocus": true,
366                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{taxzone_descrip}</b> </div>",
367                                     "triggerAction": "all",
368                                     "typeAhead": true,
369                                     "valueField": "taxzone_id",
370                                     "width": 250,
371                                     "xtype": "ComboBox",
372                                     "|xns": "Roo.form",
373                                     "items": [
374                                         {
375                                             "listeners": {
376                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n}\n"
377                                             },
378                                             "*prop": "store",
379                                             "remoteSort": true,
380                                             "xtype": "Store",
381                                             "|sortInfo": "{ direction : 'ASC', field: 'taxzone_id' }",
382                                             "|xns": "Roo.data",
383                                             "items": [
384                                                 {
385                                                     "*prop": "proxy",
386                                                     "method": "GET",
387                                                     "xtype": "HttpProxy",
388                                                     "|url": "baseURL + '/Roo/Taxzone.php'",
389                                                     "|xns": "Roo.data"
390                                                 },
391                                                 {
392                                                     "*prop": "reader",
393                                                     "id": "taxzone_id",
394                                                     "root": "data",
395                                                     "totalProperty": "total",
396                                                     "xtype": "JsonReader",
397                                                     "|fields": "[\n    {\"name\":\"taxzone_id\",\"type\":\"int\"},\n    {\"name\":\"taxzone_descrip\",\"type\":\"string\"}\n]",
398                                                     "|xns": "Roo.data"
399                                                 }
400                                             ]
401                                         }
402                                     ]
403                                 },
404                                 {
405                                     "allowBlank": true,
406                                     "displayField": "emp_name",
407                                     "editable": false,
408                                     "emptyText": "Select Purchasing Agent",
409                                     "fieldLabel": "Purchase Agent",
410                                     "forceSelection": true,
411                                     "hiddenName": "pohead_agent_username",
412                                     "listWidth": 400,
413                                     "loadingText": "Searching...",
414                                     "minChars": 2,
415                                     "name": "pohead_agent_username",
416                                     "pageSize": 20,
417                                     "qtip": "Select Purchasing Agent",
418                                     "queryParam": "query[emp_name]",
419                                     "selectOnFocus": true,
420                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{emp_name}</b> </div>",
421                                     "triggerAction": "all",
422                                     "typeAhead": true,
423                                     "valueField": "emp_name",
424                                     "width": 250,
425                                     "xtype": "ComboBox",
426                                     "|xns": "Roo.form",
427                                     "items": [
428                                         {
429                                             "listeners": {
430                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n}\n"
431                                             },
432                                             "*prop": "store",
433                                             "remoteSort": true,
434                                             "xtype": "Store",
435                                             "|sortInfo": "{ direction : 'ASC', field: 'emp_id' }",
436                                             "|xns": "Roo.data",
437                                             "items": [
438                                                 {
439                                                     "*prop": "proxy",
440                                                     "method": "GET",
441                                                     "xtype": "HttpProxy",
442                                                     "|url": "baseURL + '/Roo/Emp.php'",
443                                                     "|xns": "Roo.data"
444                                                 },
445                                                 {
446                                                     "*prop": "reader",
447                                                     "id": "emp_id",
448                                                     "root": "data",
449                                                     "totalProperty": "total",
450                                                     "xtype": "JsonReader",
451                                                     "|fields": "[\n    {\"name\":\"emp_id\",\"type\":\"int\"},\n    {\"name\":\"emp_name\",\"type\":\"string\"}\n]",
452                                                     "|xns": "Roo.data"
453                                                 }
454                                             ]
455                                         }
456                                     ]
457                                 },
458                                 {
459                                     "fieldLabel": "Comments",
460                                     "height": 100,
461                                     "name": "pohead_comments",
462                                     "width": 400,
463                                     "xtype": "TextArea",
464                                     "|xns": "Roo.form"
465                                 },
466                                 {
467                                     "name": "pohead_vend_id",
468                                     "xtype": "Hidden",
469                                     "|xns": "Roo.form"
470                                 },
471                                 {
472                                     "name": "items",
473                                     "xtype": "Hidden",
474                                     "|xns": "Roo.form"
475                                 },
476                                 {
477                                     "name": "pohead_id",
478                                     "xtype": "Hidden",
479                                     "|xns": "Roo.form"
480                                 }
481                             ]
482                         }
483                     ]
484                 },
485                 {
486                     "listeners": {
487                         "|activate": "function() {\n    _this.panel = this;\n    \n    \n    var pid = _this.form.findField('pohead_id').getValue() * 1;\n    if (pid < 1) {\n        Roo.MessageBox.alert(\"Save First\", \"Please save the purchase 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}",
488                         "deactivate": "function (_self)\n{\n     if(_this.grid){\n        var ar = [];\n\n        _this.grid.ds.each(function(r) {\n            ar.push({\n                poitem_id : r.data.poitem_id,\n                poitem_itemsite_id : r.data.poitem_itemsite_id,\n                poitem_unitprice : r.data.poitem_unitprice,\n                poitem_qty_ordered : r.data.poitem_qty_ordered\n            });\n                \n        });\n        \n        _this.form.findField('items').setValue(JSON.stringify(ar));\n    }\n    _this.dontClose = true;\n    _this.form.doAction(\"submit\");\n\n}"
489                     },
490                     "background": true,
491                     "fitContainer": true,
492                     "fitToframe": true,
493                     "region": "center",
494                     "tableName": "poitem",
495                     "title": "Order Items",
496                     "xtype": "GridPanel",
497                     "|xns": "Roo",
498                     "items": [
499                         {
500                             "listeners": {
501                                 "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
502                                 "beforeedit": "function (e)\n{\n    var r = e.record.data.poitem_qty_received * 1;\n    \n    if(r > 0){\n        Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n        return false;\n    }\n    \n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return false;\n    }\n    \n    \n}"
503                             },
504                             "*prop": "grid",
505                             "autoExpandColumn": "item_descrip1",
506                             "clicksToEdit": 1,
507                             "loadMask": true,
508                             "xtype": "EditorGrid",
509                             "|xns": "Roo.grid",
510                             "items": [
511                                 {
512                                     "listeners": {
513                                         "beforeload": "function (_self, o){\n    o.params = o.params || {};\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        return false;\n    }\n    \n    o.params.poitem_pohead_id = hid;\n    o.params._with_item = 1;\n    o.params._roo_office = _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2);\n\n}\n",
514                                         "load": "function (_self, records, options)\n{\n    _this.grid.footer.updateSummary();\n}"
515                                     },
516                                     "*prop": "dataSource",
517                                     "remoteSort": true,
518                                     "xtype": "Store",
519                                     "|sortInfo": "{ field : 'poitem_linenumber', direction: 'ASC' }",
520                                     "|xns": "Roo.data",
521                                     "items": [
522                                         {
523                                             "*prop": "proxy",
524                                             "method": "GET",
525                                             "timeout": 90000,
526                                             "xtype": "HttpProxy",
527                                             "|url": "baseURL + '/Xtuple/Roo/Poitem.php'",
528                                             "|xns": "Roo.data"
529                                         },
530                                         {
531                                             "*prop": "reader",
532                                             "id": "poitem_id",
533                                             "root": "data",
534                                             "totalProperty": "total",
535                                             "xtype": "JsonReader",
536                                             "|fields": "[\n    {\n        'name': 'poitem_id',\n        'type': 'int'\n    }\n]",
537                                             "|xns": "Roo.data"
538                                         }
539                                     ]
540                                 },
541                                 {
542                                     "|xns": "Roo",
543                                     "xtype": "Toolbar",
544                                     "*prop": "toolbar",
545                                     "items": [
546                                         {
547                                             "listeners": {
548                                                 "|click": "function()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var ct  =    _this.grid.ds.getCount();\n    \n    var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;\n    \n    var dt = _this.form.findField('pohead_orderdate').getValue();\n    \n    var nr = _this.grid.ds.reader.newRow({\n        poitem_id : 0,\n        poitem_linenumber : last,\n        item_number : '',\n        item_descrip1 : '',\n        poitem_duedate : dt,\n        poitem_qty_ordered : 1,\n        poitem_unitprice : 0\n    });\n    \n    _this.grid.stopEditing();\n    _this.grid.ds.insert(_this.grid.ds.getCount(), nr); \n    _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);\n}\n"
549                                             },
550                                             "cls": "x-btn-text-icon",
551                                             "text": "Add",
552                                             "xtype": "Button",
553                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
554                                             "|xns": "Roo.Toolbar"
555                                         },
556                                         {
557                                             "listeners": {
558                                                 "|click": "function ()\n{\n    var status = _this.form.findField('pohead_status').getValue();\n    \n    if(status == 'C'){\n        Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n        return;\n    }\n    \n    var cs = _this.grid.getSelectionModel().getSelectedCell();\n    if (!cs) {\n        Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n        return;\n    }\n    _this.grid.stopEditing();\n    var r = _this.grid.ds.getAt(cs[0]);\n    \n    if(r.data.poitem_qty_received * 1 > 0){\n        Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n        return;\n    }\n    \n    \n    _this.grid.ds.remove(r);\n   \n}"
559                                             },
560                                             "cls": "x-btn-text-icon",
561                                             "text": "Remove",
562                                             "xtype": "Button",
563                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
564                                             "|xns": "Roo.Toolbar"
565                                         }
566                                     ]
567                                 },
568                                 {
569                                     "*prop": "footer",
570                                     "displayInfo": true,
571                                     "emptyMsg": "No Item found",
572                                     "pageSize": 100,
573                                     "xtype": "PagingToolbar",
574                                     "|updateSummary": "function() {\n\r\n    var f = this;\r\n    new Pman.Request({\r\n        url : baseURL + '/Xtuple/Roo/Poitem',\r\n        method : 'GET',\r\n        params : {\n            _roo_office : _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2),\r\n            _totals : 1,\r\n            poitem_pohead_id : _this.form.findField('pohead_id').getValue()\r\n        },\r\n        success : function(d) {\n            Roo.log(d);\r\n            f.displayEl.update(String.format(\r\n                \"{0} items | Total : {1} {2}\",\r\n                d.data[0].count_item,\r\n                _this.form.findField('pohead_curr_id').el.dom.value,\r\n                d.data[0].totals\r\n            ));\r\n                \r\n        }\r\n    });\r\n\n}\n",
575                                     "|xns": "Roo"
576                                 },
577                                 {
578                                     "*prop": "colModel[]",
579                                     "align": "right",
580                                     "dataIndex": "poitem_linenumber",
581                                     "header": "Line#",
582                                     "width": 50,
583                                     "xtype": "ColumnModel",
584                                     "|renderer": "function(v) { return String.format('{0}', v); }",
585                                     "|xns": "Roo.grid"
586                                 },
587                                 {
588                                     "*prop": "colModel[]",
589                                     "dataIndex": "item_number",
590                                     "header": "Item code",
591                                     "width": 100,
592                                     "xtype": "ColumnModel",
593                                     "|renderer": "function(v) { return String.format('{0}', v); }",
594                                     "|xns": "Roo.grid",
595                                     "items": [
596                                         {
597                                             "|xns": "Roo.grid",
598                                             "xtype": "GridEditor",
599                                             "*prop": "editor",
600                                             "items": [
601                                                 {
602                                                     "listeners": {
603                                                         "beforeselect": "function (combo, record, index)\n{\n  var ar = _this.grid.activeEditor.record;\n  \n  (function() { \n      ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);\n      ar.set('poitem_itemsite_id', record.data.itemsite_id);\n  }).defer(100);\n  \n}"
604                                                     },
605                                                     "*prop": "field",
606                                                     "allowBlank": false,
607                                                     "displayField": "itemsite_item_id_item_number",
608                                                     "editable": true,
609                                                     "emptyText": "Select item",
610                                                     "forceSelection": true,
611                                                     "hiddenName": "itemsite_item_id_item_number",
612                                                     "listWidth": 400,
613                                                     "loadingText": "Searching...",
614                                                     "minChars": 2,
615                                                     "name": "item_number",
616                                                     "pageSize": 20,
617                                                     "qtip": "Select item",
618                                                     "queryParam": "query[number]",
619                                                     "selectOnFocus": true,
620                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>",
621                                                     "triggerAction": "all",
622                                                     "typeAhead": false,
623                                                     "valueField": "item_number",
624                                                     "xtype": "ComboBox",
625                                                     "|xns": "Roo.form",
626                                                     "items": [
627                                                         {
628                                                             "listeners": {
629                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {}; \n    o.params.itemsite_posupply = 1;\n}\n"
630                                                             },
631                                                             "*prop": "store",
632                                                             "remoteSort": true,
633                                                             "xtype": "Store",
634                                                             "|sortInfo": "{ direction : 'ASC', field: 'item_number' }",
635                                                             "|xns": "Roo.data",
636                                                             "items": [
637                                                                 {
638                                                                     "*prop": "proxy",
639                                                                     "method": "GET",
640                                                                     "xtype": "HttpProxy",
641                                                                     "|url": "baseURL + '/Roo/itemsite.php'",
642                                                                     "|xns": "Roo.data"
643                                                                 },
644                                                                 {
645                                                                     "*prop": "reader",
646                                                                     "id": "itemsite_id",
647                                                                     "root": "data",
648                                                                     "totalProperty": "total",
649                                                                     "xtype": "JsonReader",
650                                                                     "|fields": "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]",
651                                                                     "|xns": "Roo.data"
652                                                                 }
653                                                             ]
654                                                         }
655                                                     ]
656                                                 }
657                                             ]
658                                         }
659                                     ]
660                                 },
661                                 {
662                                     "*prop": "colModel[]",
663                                     "dataIndex": "item_descrip1",
664                                     "header": "Item description",
665                                     "width": 150,
666                                     "xtype": "ColumnModel",
667                                     "|renderer": "function(v) { return String.format('{0}', v); }",
668                                     "|xns": "Roo.grid"
669                                 },
670                                 {
671                                     "*prop": "colModel[]",
672                                     "dataIndex": "poitem_duedate",
673                                     "header": "Due date",
674                                     "width": 100,
675                                     "xtype": "ColumnModel",
676                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
677                                     "|xns": "Roo.grid"
678                                 },
679                                 {
680                                     "*prop": "colModel[]",
681                                     "align": "right",
682                                     "dataIndex": "poitem_qty_ordered",
683                                     "header": "Ordered",
684                                     "width": 75,
685                                     "xtype": "ColumnModel",
686                                     "|renderer": "function(v) { return String.format('{0}', v); }",
687                                     "|xns": "Roo.grid",
688                                     "items": [
689                                         {
690                                             "|xns": "Roo.grid",
691                                             "xtype": "GridEditor",
692                                             "*prop": "editor",
693                                             "items": [
694                                                 {
695                                                     "*prop": "field",
696                                                     "allowDecimals": false,
697                                                     "decimalPrecision": 0,
698                                                     "minValue": 1,
699                                                     "style": "text-align:right",
700                                                     "xtype": "NumberField",
701                                                     "|xns": "Roo.form"
702                                                 }
703                                             ]
704                                         }
705                                     ]
706                                 },
707                                 {
708                                     "*prop": "colModel[]",
709                                     "align": "right",
710                                     "dataIndex": "poitem_qty_received",
711                                     "header": "Received",
712                                     "width": 75,
713                                     "xtype": "ColumnModel",
714                                     "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v - r.data.poitem_qty_returned);\n}",
715                                     "|xns": "Roo.grid"
716                                 },
717                                 {
718                                     "*prop": "colModel[]",
719                                     "align": "right",
720                                     "dataIndex": "poitem_qty_vouchered",
721                                     "header": "Vouchered",
722                                     "width": 65,
723                                     "xtype": "ColumnModel",
724                                     "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != v ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v);\n}",
725                                     "|xns": "Roo.grid"
726                                 },
727                                 {
728                                     "*prop": "colModel[]",
729                                     "align": "right",
730                                     "dataIndex": "poitem_unitprice",
731                                     "header": "Unit price",
732                                     "width": 100,
733                                     "xtype": "ColumnModel",
734                                     "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }",
735                                     "|xns": "Roo.grid",
736                                     "items": [
737                                         {
738                                             "|xns": "Roo.grid",
739                                             "xtype": "GridEditor",
740                                             "*prop": "editor",
741                                             "items": [
742                                                 {
743                                                     "*prop": "field",
744                                                     "allowBlank": false,
745                                                     "allowDecimals": false,
746                                                     "decimalPrecision": 0,
747                                                     "minValue": 1,
748                                                     "style": "text-align:right",
749                                                     "xtype": "NumberField",
750                                                     "|xns": "Roo.form"
751                                                 }
752                                             ]
753                                         }
754                                     ]
755                                 }
756                             ]
757                         }
758                     ]
759                 },
760                 {
761                     "region": "center",
762                     "title": "TX",
763                     "xtype": "NestedLayoutPanel",
764                     "|xns": "Roo",
765                     "items": [
766                         {
767                             "|xns": "Roo",
768                             "xtype": "BorderLayout",
769                             "*prop": "layout",
770                             "items": [
771                                 {
772                                     "|xns": "Roo",
773                                     "xtype": "LayoutRegion",
774                                     "*prop": "center"
775                                 },
776                                 {
777                                     "*prop": "east",
778                                     "split": true,
779                                     "width": 550,
780                                     "xtype": "LayoutRegion",
781                                     "|xns": "Roo"
782                                 },
783                                 {
784                                     "listeners": {
785                                         "|activate": "function() {\n    _this.itempanel = this;\n    \n    \n    if (_this.itemgrid) {\n        _this.itemgrid.footer.onClick('first');\n    }\n}"
786                                     },
787                                     "background": false,
788                                     "fitContainer": true,
789                                     "fitToframe": true,
790                                     "region": "center",
791                                     "tableName": "poitem",
792                                     "title": "Items",
793                                     "xtype": "GridPanel",
794                                     "|xns": "Roo",
795                                     "items": [
796                                         {
797                                             "listeners": {
798                                                 "|render": "function() \n{\n    _this.itemgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.itempanel.active) {\n       this.footer.onClick('first');\n    }\n}",
799                                                 "rowclick": "function (_self, rowIndex, e)\n{\n    \n    _this.gltransgrid.footer.onClick('first');\n}"
800                                             },
801                                             "*prop": "grid",
802                                             "autoExpandColumn": "item_number",
803                                             "loadMask": true,
804                                             "xtype": "Grid",
805                                             "|xns": "Roo.grid",
806                                             "items": [
807                                                 {
808                                                     "|xns": "Roo",
809                                                     "xtype": "Toolbar",
810                                                     "*prop": "toolbar",
811                                                     "items": [
812                                                         {
813                                                             "listeners": {
814                                                                 "click": "function (_self, e)\n{\n    \n     new Pman.Download({\n        url : baseURL + '/Roo/Metasql',\n        method : 'GET',\n        timeout: 600000,\n        params : {\n            _group : 'gltrans_stock',\n            _name : 'byorder',\n            'pohead_number:text' : _this.form.findField('pohead_number').getValue(),\n            csvCols : '*',\n            csvTitles : '*', \n            limit : 9999       \n        }\n    });\n}"
815                                                             },
816                                                             "text": "PO analysis",
817                                                             "xtype": "Button",
818                                                             "|xns": "Roo.Toolbar"
819                                                         }
820                                                     ]
821                                                 },
822                                                 {
823                                                     "*prop": "sm",
824                                                     "singleSelect": true,
825                                                     "xtype": "RowSelectionModel",
826                                                     "|xns": "Roo.grid"
827                                                 },
828                                                 {
829                                                     "listeners": {
830                                                         "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    var hid = _this.form.findField('pohead_id').getValue();\n    \n    if(!hid.length){\n        return false;\n    }\n    \n    o.params.poitem_pohead_id = hid;\n    \n    o.params._with_item = 1;\n    \n}",
831                                                         "load": "function (_self, records, options)\n{\n    _this.gltransgrid.footer.onClick('first');\n}"
832                                                     },
833                                                     "*prop": "dataSource",
834                                                     "remoteSort": true,
835                                                     "xtype": "Store",
836                                                     "|sortInfo": "{ field : 'poitem_id', direction: 'ASC' }",
837                                                     "|xns": "Roo.data",
838                                                     "items": [
839                                                         {
840                                                             "*prop": "proxy",
841                                                             "method": "GET",
842                                                             "xtype": "HttpProxy",
843                                                             "|url": "baseURL + '/Roo/poitem.php'",
844                                                             "|xns": "Roo.data"
845                                                         },
846                                                         {
847                                                             "|xns": "Roo.data",
848                                                             "xtype": "JsonReader",
849                                                             "totalProperty": "total",
850                                                             "root": "data",
851                                                             "*prop": "reader",
852                                                             "id": "id",
853                                                             "|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]"
854                                                         }
855                                                     ]
856                                                 },
857                                                 {
858                                                     "*prop": "footer",
859                                                     "displayInfo": false,
860                                                     "displayMsg": "Displaying poitem{0} - {1} of {2}",
861                                                     "emptyMsg": "No item found",
862                                                     "pageSize": 25,
863                                                     "xtype": "PagingToolbar",
864                                                     "|xns": "Roo"
865                                                 },
866                                                 {
867                                                     "*prop": "colModel[]",
868                                                     "dataIndex": "poitem_linenumber",
869                                                     "header": "Line #",
870                                                     "width": 25,
871                                                     "xtype": "ColumnModel",
872                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
873                                                     "|xns": "Roo.grid"
874                                                 },
875                                                 {
876                                                     "*prop": "colModel[]",
877                                                     "dataIndex": "item_number",
878                                                     "header": "Item #",
879                                                     "width": 75,
880                                                     "xtype": "ColumnModel",
881                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
882                                                     "|xns": "Roo.grid"
883                                                 },
884                                                 {
885                                                     "*prop": "colModel[]",
886                                                     "dataIndex": "poitem_qty_ordered",
887                                                     "header": "Ordered",
888                                                     "width": 50,
889                                                     "xtype": "ColumnModel",
890                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
891                                                     "|xns": "Roo.grid"
892                                                 },
893                                                 {
894                                                     "*prop": "colModel[]",
895                                                     "dataIndex": "poitem_qty_received",
896                                                     "header": "Received",
897                                                     "width": 50,
898                                                     "xtype": "ColumnModel",
899                                                     "|renderer": "function(v,x,r) \n{\n    \n\n    var recv = (v- r.data.poitem_qty_returned);\n    if (recv !=  r.data.tx_qty) {\n        return String.format('<s style=\"color:red;font-weight:bold\">{0}</s>{1} ', recv, \n            (r.data.tx_qty *1).toFixed(0)        ) ;      \n    }\n    return String.format('{0}', (v- r.data.poitem_qty_returned)) ;  \n    \n}",
900                                                     "|xns": "Roo.grid"
901                                                 },
902                                                 {
903                                                     "*prop": "colModel[]",
904                                                     "dataIndex": "poitem_unitprice",
905                                                     "header": "Unit Price",
906                                                     "width": 75,
907                                                     "xtype": "ColumnModel",
908                                                     "|renderer": "function(v,x,r) \n{\n     \n    return String.format('{0}', (v- r.data.poitem_qty_returned) ? parseFloat(v- r.data.poitem_qty_returned).toFixed(3) : '') ;  \n    \n}",
909                                                     "|xns": "Roo.grid"
910                                                 }
911                                             ]
912                                         }
913                                     ]
914                                 },
915                                 {
916                                     "listeners": {
917                                         "|activate": "function() {\n    _this.gltranspanel = this;\n    //if (_this.gltransgrid) {\n    //    _this.gltransgrid.footer.onClick('first');\n    // }\n}"
918                                     },
919                                     "background": false,
920                                     "fitContainer": true,
921                                     "fitToframe": true,
922                                     "region": "east",
923                                     "tableName": "Gltrans",
924                                     "title": "Gltrans",
925                                     "xtype": "GridPanel",
926                                     "|xns": "Roo",
927                                     "items": [
928                                         {
929                                             "listeners": {
930                                                 "|render": "function() \n{\n    _this.gltransgrid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n  //  if (_this.gltranspanel.active) {\n  //     this.footer.onClick('first');\n  //  }\n}"
931                                             },
932                                             "*prop": "grid",
933                                             "autoExpandColumn": "gltrans_notes",
934                                             "loadMask": true,
935                                             "xtype": "Grid",
936                                             "|xns": "Roo.grid",
937                                             "items": [
938                                                 {
939                                                     "*prop": "sm",
940                                                     "singleSelect": true,
941                                                     "xtype": "RowSelectionModel",
942                                                     "|xns": "Roo.grid"
943                                                 },
944                                                 {
945                                                     "listeners": {
946                                                         "beforeload": "function (_self, o)\n{\n    o.params = o.params || {};\n    \n    var s = _this.itemgrid.getSelectionModel().getSelected();\n    if(!s){\n        this.removeAll();\n        return false;\n    }\n    \n    o.params._poview = 1;\n    o.params.gltrans_deleted = 0;\n    o.params.gltrans_doctype = 'PO';\n    o.params._linenumber = s.data.poitem_linenumber;\n    o.params._item = s.data.item_number;\n    o.params._ponumber = _this.form.findField('pohead_number').getValue();\n    \n}"
947                                                     },
948                                                     "*prop": "dataSource",
949                                                     "remoteSort": true,
950                                                     "xtype": "Store",
951                                                     "|sortInfo": "{ field : 'gltrans_id', direction: 'ASC' }",
952                                                     "|xns": "Roo.data",
953                                                     "items": [
954                                                         {
955                                                             "*prop": "proxy",
956                                                             "method": "GET",
957                                                             "xtype": "HttpProxy",
958                                                             "|url": "baseURL + '/Roo/gltrans.php'",
959                                                             "|xns": "Roo.data"
960                                                         },
961                                                         {
962                                                             "|xns": "Roo.data",
963                                                             "xtype": "JsonReader",
964                                                             "totalProperty": "total",
965                                                             "root": "data",
966                                                             "*prop": "reader",
967                                                             "id": "id",
968                                                             "|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]"
969                                                         }
970                                                     ]
971                                                 },
972                                                 {
973                                                     "*prop": "footer",
974                                                     "displayInfo": true,
975                                                     "displayMsg": "Displaying gltrans{0} - {1} of {2}",
976                                                     "emptyMsg": "No gltrans found",
977                                                     "pageSize": 25,
978                                                     "xtype": "PagingToolbar",
979                                                     "|xns": "Roo"
980                                                 },
981                                                 {
982                                                     "*prop": "toolbar",
983                                                     "xtype": "Toolbar",
984                                                     "|xns": "Roo",
985                                                     "items": [
986                                                         {
987                                                             "|xns": "Roo.Toolbar",
988                                                             "xtype": "Fill"
989                                                         },
990                                                         {
991                                                             "text": "Apply fixes",
992                                                             "xtype": "Button",
993                                                             "|xns": "Roo.Toolbar",
994                                                             "items": [
995                                                                 {
996                                                                     "|xns": "Roo.menu",
997                                                                     "xtype": "Menu",
998                                                                     "*prop": "menu",
999                                                                     "items": [
1000                                                                         {
1001                                                                             "listeners": {
1002                                                                                 "|click": "function()\n{\n   var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    \n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            mask : 'sending',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _recv_fix : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    \n    \n    \n    \n    \n}\n"
1003                                                                             },
1004                                                                             "cls": "x-btn-text-icon",
1005                                                                             "text": "Repost goods reciept",
1006                                                                             "xtype": "Item",
1007                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1008                                                                             "|xns": "Roo.menu"
1009                                                                         },
1010                                                                         {
1011                                                                             "|xns": "Roo.menu",
1012                                                                             "xtype": "Separator"
1013                                                                         },
1014                                                                         {
1015                                                                             "listeners": {
1016                                                                                 "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var fixit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _unitcost : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to fix the unit cost of \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            fixit();\n            return;\n        }\n    ); \n    \n    \n}\n"
1017                                                                             },
1018                                                                             "cls": "x-btn-text-icon",
1019                                                                             "text": "Fix Unit Cost",
1020                                                                             "xtype": "Item",
1021                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1022                                                                             "|xns": "Roo.menu"
1023                                                                         },
1024                                                                         {
1025                                                                             "|xns": "Roo.menu",
1026                                                                             "xtype": "Separator"
1027                                                                         },
1028                                                                         {
1029                                                                             "listeners": {
1030                                                                                 "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var addv = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _variance : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to add all the variance for \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            addv();\n            return;\n        }\n    ); \n    \n    \n}\n"
1031                                                                             },
1032                                                                             "cls": "x-btn-text-icon",
1033                                                                             "text": "Add All Variance",
1034                                                                             "xtype": "Item",
1035                                                                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
1036                                                                             "|xns": "Roo.menu"
1037                                                                         },
1038                                                                         {
1039                                                                             "listeners": {
1040                                                                                 "|click": "function()\n{\n    var s = _this.gltransgrid.getSelectionModel().getSelected();\n    \n    if(!s){\n        Roo.MessageBox.alert('Error','Please select a transaction');\n        return;\n    }\n    \n    if(s.data.gltrans_misc_id != -1){\n        Roo.MessageBox.alert('Error','Just allow to delete the variance');\n        return;\n    }\n    \n    var delit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/Gltrans.php',\n            method :'POST',\n            params : {\n                gltrans_id : s.data.gltrans_id,\n                _del : 1\n                \n            },\n            success : function(res) {\n                _this.gltransgrid.footer.onClick('refresh');\n                \n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to delete ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            delit();\n            return;\n        }\n    ); \n    \n    \n}\n"
1041                                                                             },
1042                                                                             "cls": "x-btn-text-icon",
1043                                                                             "text": "Delete Variance",
1044                                                                             "xtype": "Item",
1045                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1046                                                                             "|xns": "Roo.menu"
1047                                                                         },
1048                                                                         {
1049                                                                             "listeners": {
1050                                                                                 "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var delv = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _del : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to delete the variance on voucher of \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            delv();\n            return;\n        }\n    ); \n    \n    \n}\n"
1051                                                                             },
1052                                                                             "cls": "x-btn-text-icon",
1053                                                                             "text": "Delete Varinace on voucher",
1054                                                                             "xtype": "Item",
1055                                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1056                                                                             "|xns": "Roo.menu"
1057                                                                         },
1058                                                                         {
1059                                                                             "|xns": "Roo.menu",
1060                                                                             "xtype": "Separator"
1061                                                                         },
1062                                                                         {
1063                                                                             "listeners": {
1064                                                                                 "|click": "function()\n{\n    var pohead_number = _this.form.findField('pohead_number').getValue();\n    var pohead_id = _this.form.findField('pohead_id').getValue();\n        \n    var addv = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/pohead.php',\n            method :'POST',\n            params : {\n                pohead_id : pohead_id,\n                _fix_voids : 1\n                \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to add all the fix the voids for \" + pohead_number + \" ?\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            addv();\n            return;\n        }\n    ); \n    \n    \n}\n"
1065                                                                             },
1066                                                                             "cls": "x-btn-text-icon",
1067                                                                             "text": "Recalculate voids",
1068                                                                             "xtype": "Item",
1069                                                                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
1070                                                                             "|xns": "Roo.menu"
1071                                                                         }
1072                                                                     ]
1073                                                                 }
1074                                                             ]
1075                                                         },
1076                                                         {
1077                                                             "listeners": {
1078                                                                 "|click": "function()\n{\n    var s = _this.gltransgrid.selModel.getSelected();\n    if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select an item to reverse\");\n        return;\n    }\n    \n    var fixit = function(){\n        new Pman.Request({\n            url : baseURL + '/Roo/invdetail.php',\n            method :'POST',\n            params : {\n               \n                _reverse :  s.data.invdetail_id \n            },\n            success : function(res) {\n                Roo.MessageBox.alert('Notice', 'DONE');\n            }\n        });\n    }\n    \n    Roo.MessageBox.confirm(\n        \"Confirm\",\n        \"Are you sure to reverse that line\",\n        function(r) {\n            if (r != 'yes') {\n                return;\n            }\n\n            fixit();\n            return;\n        }\n    ); \n    \n    \n}\n"
1079                                                             },
1080                                                             "cls": "x-btn-text-icon",
1081                                                             "text": "Reverse",
1082                                                             "xtype": "Button",
1083                                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
1084                                                             "|xns": "Roo.Toolbar"
1085                                                         }
1086                                                     ]
1087                                                 },
1088                                                 {
1089                                                     "*prop": "colModel[]",
1090                                                     "dataIndex": "gltrans_id",
1091                                                     "header": "ID",
1092                                                     "width": 50,
1093                                                     "xtype": "ColumnModel",
1094                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1095                                                     "|xns": "Roo.grid"
1096                                                 },
1097                                                 {
1098                                                     "*prop": "colModel[]",
1099                                                     "dataIndex": "gltrans_date",
1100                                                     "header": "Date",
1101                                                     "width": 75,
1102                                                     "xtype": "ColumnModel",
1103                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
1104                                                     "|xns": "Roo.grid"
1105                                                 },
1106                                                 {
1107                                                     "*prop": "colModel[]",
1108                                                     "dataIndex": "gltrans_docnumber",
1109                                                     "header": "doc #",
1110                                                     "width": 80,
1111                                                     "xtype": "ColumnModel",
1112                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1113                                                     "|xns": "Roo.grid"
1114                                                 },
1115                                                 {
1116                                                     "*prop": "colModel[]",
1117                                                     "align": "right",
1118                                                     "dataIndex": "location_name",
1119                                                     "header": "Location",
1120                                                     "width": 60,
1121                                                     "xtype": "ColumnModel",
1122                                                     "|renderer": "function(v,x,r) {\n  \n   \n    return String.format('{0}', v); \n\n}",
1123                                                     "|xns": "Roo.grid"
1124                                                 },
1125                                                 {
1126                                                     "*prop": "colModel[]",
1127                                                     "align": "right",
1128                                                     "dataIndex": "gltrans_amount",
1129                                                     "header": "Amount",
1130                                                     "width": 100,
1131                                                     "xtype": "ColumnModel",
1132                                                     "|renderer": "function(v,x,r) { \n return String.format('{0}', v); \n\n}",
1133                                                     "|xns": "Roo.grid"
1134                                                 },
1135                                                 {
1136                                                     "*prop": "colModel[]",
1137                                                     "align": "right",
1138                                                     "dataIndex": "invdetail_qty",
1139                                                     "header": "Qty",
1140                                                     "width": 60,
1141                                                     "xtype": "ColumnModel",
1142                                                     "|renderer": "function(v,x,r) {\n   var f = r.data.invfifo_void * 1 ? '<s>{0}</s>' : '{0}';\n   \n    return String.format(f, (v*1).toFixed(0)); \n\n}",
1143                                                     "|xns": "Roo.grid"
1144                                                 },
1145                                                 {
1146                                                     "*prop": "colModel[]",
1147                                                     "dataIndex": "gltrans_notes",
1148                                                     "header": "Notes",
1149                                                     "width": 100,
1150                                                     "xtype": "ColumnModel",
1151                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1152                                                     "|xns": "Roo.grid"
1153                                                 }
1154                                             ]
1155                                         }
1156                                     ]
1157                                 }
1158                             ]
1159                         }
1160                     ]
1161                 },
1162                 {
1163                     "region": "center",
1164                     "title": "GL Tx",
1165                     "xtype": "NestedLayoutPanel",
1166                     "|xns": "Roo",
1167                     "items": [
1168                         {
1169                             "|xns": "Roo",
1170                             "xtype": "BorderLayout",
1171                             "*prop": "layout",
1172                             "items": [
1173                                 {
1174                                     "|xns": "Roo",
1175                                     "xtype": "LayoutRegion",
1176                                     "*prop": "center"
1177                                 },
1178                                 {
1179                                     "*prop": "east",
1180                                     "split": true,
1181                                     "width": 500,
1182                                     "xtype": "LayoutRegion",
1183                                     "|xns": "Roo"
1184                                 },
1185                                 {
1186                                     "listeners": {
1187                                         "|activate": "function() {\n    _this.gltxpanel = this;\n    if (_this.gltxgrid) {\n        _this.gltxgrid.footer.onClick('first');\n    }\n}"
1188                                     },
1189                                     "background": false,
1190                                     "fitContainer": true,
1191                                     "fitToframe": true,
1192                                     "region": "center",
1193                                     "tableName": "invdetail",
1194                                     "title": "invdetail",
1195                                     "xtype": "GridPanel",
1196                                     "|xns": "Roo",
1197                                     "items": [
1198                                         {
1199                                             "listeners": {
1200                                                 "|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}",
1201                                                 "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}"
1202                                             },
1203                                             "*prop": "grid",
1204                                             "autoExpandColumn": "gltrans_accnt_id_accnt_descrip",
1205                                             "loadMask": true,
1206                                             "xtype": "Grid",
1207                                             "|xns": "Roo.grid",
1208                                             "items": [
1209                                                 {
1210                                                     "listeners": {
1211                                                         "selectionchange": "function (_self)\n{\n    _this.gltxdgrid.footer.onClick('first');;\n}"
1212                                                     },
1213                                                     "*prop": "sm",
1214                                                     "singleSelect": true,
1215                                                     "xtype": "RowSelectionModel",
1216                                                     "|xns": "Roo.grid"
1217                                                 },
1218                                                 {
1219                                                     "listeners": {
1220                                                         "beforeload": "function (_self, o)\n{\n    o.params.pohead_id = _this.form.findField('pohead_id').getValue();\n    if (! o.params.pohead_id ) {\n        this.removeAll();\n        return false;\n    }\n    o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;\n}",
1221                                                         "load": "function (_self, records, options)\n{\n _this.gltxdgrid.footer.onClick('first');\n}"
1222                                                     },
1223                                                     "*prop": "dataSource",
1224                                                     "remoteSort": true,
1225                                                     "xtype": "Store",
1226                                                     "|sortInfo": "{ field : 'item_number', direction: 'ASC' }",
1227                                                     "|xns": "Roo.data",
1228                                                     "items": [
1229                                                         {
1230                                                             "*prop": "proxy",
1231                                                             "method": "GET",
1232                                                             "xtype": "HttpProxy",
1233                                                             "|url": "baseURL + '/Roo/gltrans.php'",
1234                                                             "|xns": "Roo.data"
1235                                                         },
1236                                                         {
1237                                                             "|xns": "Roo.data",
1238                                                             "xtype": "JsonReader",
1239                                                             "totalProperty": "total",
1240                                                             "root": "data",
1241                                                             "*prop": "reader",
1242                                                             "id": "id",
1243                                                             "|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]"
1244                                                         }
1245                                                     ]
1246                                                 },
1247                                                 {
1248                                                     "*prop": "footer",
1249                                                     "displayInfo": true,
1250                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
1251                                                     "emptyMsg": "No invdetail found",
1252                                                     "pageSize": 9999,
1253                                                     "xtype": "PagingToolbar",
1254                                                     "|xns": "Roo",
1255                                                     "items": [
1256                                                         {
1257                                                             "listeners": {
1258                                                                 "render": "function (_self)\n{\n    _this.glsalesbtn = _self;\n}",
1259                                                                 "click": "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
1260                                                             },
1261                                                             "enableToggle": true,
1262                                                             "pressed": true,
1263                                                             "text": "Split sales",
1264                                                             "xtype": "Button",
1265                                                             "|xns": "Roo.Toolbar"
1266                                                         }
1267                                                     ]
1268                                                 },
1269                                                 {
1270                                                     "*prop": "colModel[]",
1271                                                     "dataIndex": "gltrans_as_summary",
1272                                                     "header": "Summary",
1273                                                     "width": 50,
1274                                                     "xtype": "ColumnModel",
1275                                                     "|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 }",
1276                                                     "|xns": "Roo.grid"
1277                                                 },
1278                                                 {
1279                                                     "*prop": "colModel[]",
1280                                                     "dataIndex": "gltrans_accnt_id_accnt_descrip",
1281                                                     "header": "Account",
1282                                                     "width": 75,
1283                                                     "xtype": "ColumnModel",
1284                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1285                                                     "|xns": "Roo.grid"
1286                                                 },
1287                                                 {
1288                                                     "*prop": "colModel[]",
1289                                                     "align": "right",
1290                                                     "dataIndex": "gltrans_amount_credit",
1291                                                     "header": "Credit",
1292                                                     "width": 75,
1293                                                     "xtype": "ColumnModel",
1294                                                     "|renderer": "function(v) { return String.format('{0}',  Roo.util.Format.number(v,3)); }",
1295                                                     "|xns": "Roo.grid"
1296                                                 },
1297                                                 {
1298                                                     "*prop": "colModel[]",
1299                                                     "align": "right",
1300                                                     "dataIndex": "gltrans_amount_debit",
1301                                                     "header": "Debit",
1302                                                     "width": 75,
1303                                                     "xtype": "ColumnModel",
1304                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
1305                                                     "|xns": "Roo.grid"
1306                                                 },
1307                                                 {
1308                                                     "*prop": "colModel[]",
1309                                                     "align": "right",
1310                                                     "dataIndex": "gltrans_amount_total",
1311                                                     "header": "Sum",
1312                                                     "width": 75,
1313                                                     "xtype": "ColumnModel",
1314                                                     "|renderer": "function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }",
1315                                                     "|xns": "Roo.grid"
1316                                                 },
1317                                                 {
1318                                                     "*prop": "colModel[]",
1319                                                     "align": "right",
1320                                                     "dataIndex": "gltrans_amount_total_unposted",
1321                                                     "header": "Unposted",
1322                                                     "width": 75,
1323                                                     "xtype": "ColumnModel",
1324                                                     "|renderer": "function(v) { return String.format('<span style=\"color:red\">{0}</span>', Roo.util.Format.number(v,3)); }",
1325                                                     "|xns": "Roo.grid"
1326                                                 }
1327                                             ]
1328                                         }
1329                                     ]
1330                                 },
1331                                 {
1332                                     "listeners": {
1333                                         "|activate": "function() {\n    _this.gltxdpanel = this;\n    if (_this.gltxdgrid) {\n        _this.gltxdgrid.footer.onClick('first');\n    }\n}"
1334                                     },
1335                                     "background": false,
1336                                     "fitContainer": true,
1337                                     "fitToframe": true,
1338                                     "region": "east",
1339                                     "tableName": "invdetail",
1340                                     "title": "invdetail",
1341                                     "xtype": "GridPanel",
1342                                     "|xns": "Roo",
1343                                     "items": [
1344                                         {
1345                                             "listeners": {
1346                                                 "|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}",
1347                                                 "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}"
1348                                             },
1349                                             "*prop": "grid",
1350                                             "autoExpandColumn": "gltrans_notes",
1351                                             "loadMask": true,
1352                                             "xtype": "Grid",
1353                                             "|xns": "Roo.grid",
1354                                             "items": [
1355                                                 {
1356                                                     "|xns": "Roo",
1357                                                     "xtype": "Toolbar",
1358                                                     "*prop": "toolbar",
1359                                                     "items": [
1360                                                         {
1361                                                             "listeners": {
1362                                                                 "render": "function (_self)\n{\n    _this.glvoidshow = _self;\n}",
1363                                                                 "click": "function (_self, e)\n{\n    (function()  { _this.gltxgrid.footer.onClick('first'); }).defer(100);\n}"
1364                                                             },
1365                                                             "enableToggle": true,
1366                                                             "pressed": true,
1367                                                             "text": "Hide Void",
1368                                                             "xtype": "Button",
1369                                                             "|xns": "Roo.Toolbar"
1370                                                         },
1371                                                         {
1372                                                             "|xns": "Roo.Toolbar",
1373                                                             "xtype": "Fill"
1374                                                         },
1375                                                         {
1376                                                             "listeners": {
1377                                                                 "click": "function (_self, e)\n{\n    new Pman.Request( {\n        url : baseURL + '/Roo/Gltrans',\n        method : 'GET',\n        mask:  'sending',\n        params : {\n            pohead_id : _this.form.findField('pohead_id').getValue(),\n            _autovoid : 1\n        },\n        success : function() {\n            _this.gltxpanel.footer.onClick('first');\n        }\n            \n    \n    });\n}"
1378                                                             },
1379                                                             "text": "AutoVoid",
1380                                                             "xtype": "Button",
1381                                                             "|xns": "Roo.Toolbar"
1382                                                         }
1383                                                     ]
1384                                                 },
1385                                                 {
1386                                                     "listeners": {
1387                                                         "beforeload": "function (_self, o)\n{\n    o.params.pohead_id = _this.form.findField('pohead_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     o.params._hide_void = _this.glvoidshow.pressed ? 1 : 0;\n    //glvoidshow\n    \n}"
1388                                                     },
1389                                                     "*prop": "dataSource",
1390                                                     "remoteSort": true,
1391                                                     "xtype": "Store",
1392                                                     "|sortInfo": "{ field : 'gltrans_docnumber', direction: 'ASC' }",
1393                                                     "|xns": "Roo.data",
1394                                                     "items": [
1395                                                         {
1396                                                             "*prop": "proxy",
1397                                                             "method": "GET",
1398                                                             "xtype": "HttpProxy",
1399                                                             "|url": "baseURL + '/Roo/gltrans.php'",
1400                                                             "|xns": "Roo.data"
1401                                                         },
1402                                                         {
1403                                                             "|xns": "Roo.data",
1404                                                             "xtype": "JsonReader",
1405                                                             "totalProperty": "total",
1406                                                             "root": "data",
1407                                                             "*prop": "reader",
1408                                                             "id": "id",
1409                                                             "|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]"
1410                                                         }
1411                                                     ]
1412                                                 },
1413                                                 {
1414                                                     "*prop": "footer",
1415                                                     "displayInfo": true,
1416                                                     "displayMsg": "Displaying invdetail{0} - {1} of {2}",
1417                                                     "emptyMsg": "No invdetail found",
1418                                                     "pageSize": 9999,
1419                                                     "xtype": "PagingToolbar",
1420                                                     "|xns": "Roo",
1421                                                     "items": [
1422                                                         {
1423                                                             "listeners": {
1424                                                                 "click": "function (_self, e)\n{\n    new Pman.Download( {\n        grid : _this.gltxdgrid\n    \n    });\n}"
1425                                                             },
1426                                                             "text": "Download",
1427                                                             "xtype": "Button",
1428                                                             "|xns": "Roo.Toolbar"
1429                                                         }
1430                                                     ]
1431                                                 },
1432                                                 {
1433                                                     "*prop": "colModel[]",
1434                                                     "dataIndex": "gltrans_id",
1435                                                     "header": "Ref#",
1436                                                     "sortable": true,
1437                                                     "width": 75,
1438                                                     "xtype": "ColumnModel",
1439                                                     "|renderer": "function(v) { return String.format('{0}', v ); }",
1440                                                     "|xns": "Roo.grid"
1441                                                 },
1442                                                 {
1443                                                     "*prop": "colModel[]",
1444                                                     "dataIndex": "gltrans_date",
1445                                                     "header": "Date",
1446                                                     "width": 75,
1447                                                     "xtype": "ColumnModel",
1448                                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
1449                                                     "|xns": "Roo.grid"
1450                                                 },
1451                                                 {
1452                                                     "*prop": "colModel[]",
1453                                                     "dataIndex": "gltrans_docnumber",
1454                                                     "header": "Doc#",
1455                                                     "width": 75,
1456                                                     "xtype": "ColumnModel",
1457                                                     "|renderer": "function(v,x,r) { \n\n    var style = '';\n    if (r.data.gltrans_misc_id > 0 && (r.data.invdetail_id *1) < 1) {\n        style = ' style=\"color:red;font-weight:bold\"';\n   }\n    if (r.data.gltrans_deleted) {\n       return String.format('<s'+style+'>{0}</s>', v);     \n    }\n    return String.format('<span' + style + '>{0}</span>', v); \n}",
1458                                                     "|xns": "Roo.grid"
1459                                                 },
1460                                                 {
1461                                                     "*prop": "colModel[]",
1462                                                     "dataIndex": "gltrans_source",
1463                                                     "header": "Source",
1464                                                     "width": 50,
1465                                                     "xtype": "ColumnModel",
1466                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1467                                                     "|xns": "Roo.grid"
1468                                                 },
1469                                                 {
1470                                                     "*prop": "colModel[]",
1471                                                     "dataIndex": "gltrans_notes",
1472                                                     "header": "Notes",
1473                                                     "width": 75,
1474                                                     "xtype": "ColumnModel",
1475                                                     "|renderer": "function(v) { return String.format('{0}', v); }",
1476                                                     "|xns": "Roo.grid"
1477                                                 },
1478                                                 {
1479                                                     "*prop": "colModel[]",
1480                                                     "align": "right",
1481                                                     "dataIndex": "gltrans_amount",
1482                                                     "header": "Amount",
1483                                                     "width": 75,
1484                                                     "xtype": "ColumnModel",
1485                                                     "|renderer": "function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }",
1486                                                     "|xns": "Roo.grid"
1487                                                 },
1488                                                 {
1489                                                     "*prop": "colModel[]",
1490                                                     "dataIndex": "gltrans_posted",
1491                                                     "header": "Posted",
1492                                                     "width": 50,
1493                                                     "xtype": "ColumnModel",
1494                                                     "|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 }",
1495                                                     "|xns": "Roo.grid"
1496                                                 }
1497                                             ]
1498                                         }
1499                                     ]
1500                                 }
1501                             ]
1502                         }
1503                     ]
1504                 },
1505                 {
1506                     "listeners": {
1507                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
1508                     },
1509                     "*prop": "buttons[]",
1510                     "text": "Cancel",
1511                     "xtype": "Button",
1512                     "|xns": "Roo"
1513                 },
1514                 {
1515                     "listeners": {
1516                         "click": "function (_self, e)\n{\n    if(_this.grid){\n        var ar = [];\n        var err = false;\n        _this.grid.ds.each(function(r) {\n            if(r.data.poitem_unitprice < 1){\n                err = true;\n                return;\n            }\n            ar.push({\n                poitem_id : r.data.poitem_id,\n                poitem_itemsite_id : r.data.poitem_itemsite_id,\n                poitem_unitprice : r.data.poitem_unitprice,\n                poitem_qty_ordered : r.data.poitem_qty_ordered\n            });\n                \n        });\n \n        if(err){\n            Roo.MessageBox.alert('Error','Unit Price does not allow $0' );\n            return;\n        }   \n               \n        _this.form.findField('items').setValue(JSON.stringify(ar));\n    }\n        \n    _this.form.doAction(\"submit\");\n\n}",
1517                         "render": "function (_self)\n{\n    _this.saveBtn = _self;\n}"
1518                     },
1519                     "*prop": "buttons[]",
1520                     "text": "Save",
1521                     "xtype": "Button",
1522                     "|xns": "Roo"
1523                 }
1524             ]
1525         }
1526     ],
1527     "permname": "",
1528     "modOrder": "001"
1529 }