Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Tab.XtupleItem.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.XtupleItem = new Roo.XComponent({
8
9  _strings : {
10   'be53a0541a6d36f6ecb879fa2c584b08' :"Image",
11   '41e902bb1b2db625736ede3bacc41fe0' :"is Sold?",
12   'ce4ee01637f4279d02d0f232459dc9a4' :"Purchased",
13   '1be6f9eb563f3bf85c78b4219bf09de9' :"Brand",
14   'aa554e9e2270df2127bfe9096f1bd9ce' :"Displaying item{0} - {1} of {2}",
15   'ce5bf551379459c1c61d2a204061c455' :"Location",
16   '44ca8ce0e02dee5d520525ac21bcbee9' :"Sync Product from HK (Based on Search)",
17   '068f80c7519d0528fb08e82137a72131' :"Products",
18   '68f43fdcf074903d65da764642a4b968' :"is Active?",
19   '759d259249621c817551c5fe726d5c57' :"itemloc",
20   '89217b1527e14cced20e78111a8f5027' :"Item prodcat",
21   'e924991fc4c883bc237e69efe884d674' :"Download Sales Report",
22   'ee3585dbcb1e8f8826f3403c1e9d898c' :"Rename SKU",
23   '20b4f77bd00b4f63a49ec8e08f3bf6a6' :"Cost",
24   'fe78f3efbfa84d8485d589031596c5b8' :"Pallet",
25   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
26   '19029645d5286771ac708d1bcd118bf4' :"Displaying itemloc{0} - {1} of {2}",
27   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
28   '99a808d8d16122d70e44bd7f709d30fb' :"Balance",
29   '9a8faafb674c03474827bcb6fcde43a3' :"Search Product",
30   'f1c3ca6cadc4a9f57a08d5f7482a3f83' :"No item found",
31   'd6ea9efa48916e9563d76ddc233ebe2a' :"Sync Product from HK (New Products Only)",
32   'ec53a8c4f07baed5d8825072c89799be' :"Status",
33   '2cfd827c6e37453fe1ddde82a5bd9474' :"No itemloc found",
34   'd8ab3576a67fe0cc175ee77d57d0fd85' :"Pickface",
35   '5bc3fd20294c17c9803942958fd7f26d' :"Show Inactive",
36   '70cd7e06502a63356290711ec3b11223' :"Upload new products and costs",
37   'c6ca371871d835c79c8654b5cd788cc7' :"Product Group",
38   '695dbdb13fad32669a68d8fec8541c7f' :"Download Standard costs",
39   '156567f65fc207d39cadbf045687c521' :"Itemloc qty",
40   'c2f1d503b95bf9f3aa4d775a216c5c73' :"Sync Product Data from HK",
41   '36c454c4130e4444e8410f11d6d998f0' :"Tools - Upload/Download",
42   'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
43   '7fee866379427143414dd7a72e56414b' :"Report start :",
44   'a9e35d03ee7f31f5bb199379a6d3547a' :"Select Brand",
45   '35be52be39d3efcd0cd2b3721fc3c298' :"Cost (base)",
46   '750587d31c68779e7f615c190a9dc23f' :"Last purchase price",
47   'b2ee912b91d69b435159c7c3f6df7f5f' :"Number",
48   '173cf046739c17fd7c97ec3540d58807' :"(function() { return (new Date()).format('Y') + '-01-01'; })()",
49   'c20ad4d76fe97759aa27a0c99bff6710' :"12"
50  },
51
52   part     :  ["Xtuple", "Item" ],
53   order    : '001-Pman.Tab.XtupleItem',
54   region   : 'center',
55   parent   : 'Pman.Tab.XtupleManage',
56   name     : "Pman.Tab.XtupleItem",
57   disabled : false, 
58   permname : '', 
59   _tree : function()
60   {
61    var _this = this;
62    var MODULE = this;
63    return {
64    background : false,
65    region : 'center',
66    title : _this._strings['068f80c7519d0528fb08e82137a72131'] /* Products */,
67    xns : Roo,
68    '|xns' : 'Roo',
69    xtype : 'NestedLayoutPanel',
70    layout : {
71     xns : Roo,
72     '|xns' : 'Roo',
73     xtype : 'BorderLayout',
74     center : {
75      xns : Roo,
76      '|xns' : 'Roo',
77      xtype : 'LayoutRegion'
78     },
79     east : {
80      split : true,
81      width : 200,
82      xns : Roo,
83      '|xns' : 'Roo',
84      xtype : 'LayoutRegion'
85     },
86     items  : [
87      {
88       background : false,
89       fitContainer : true,
90       fitToframe : true,
91       region : 'center',
92       tableName : 'item',
93       title : _this._strings['068f80c7519d0528fb08e82137a72131'] /* Products */,
94       xns : Roo,
95       '|xns' : 'Roo',
96       xtype : 'GridPanel',
97       listeners : {
98        activate : function() {
99             _this.panel = this;
100             if (_this.grid) {
101                 _this.grid.footer.onClick('first');
102             }
103         }
104       },
105       grid : {
106        autoExpandColumn : 'item_descrip1',
107        clicksToEdit : 1,
108        loadMask : true,
109        xns : Roo.grid,
110        '|xns' : 'Roo.grid',
111        xtype : 'EditorGrid',
112        listeners : {
113         afteredit : function (e)
114          {
115              
116              
117              Roo.log(e);
118              new Pman.Request({
119                  url : baseURL +'/Roo/Charass',
120                  params : {
121                       charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
122                       charass_value : e.value,
123                       charass_target_type : 'I',
124                       charass_default : 1,
125                       charass_target_id : e.record.data.item_id
126                   },
127                   method : 'POST'
128               });
129              
130              
131              e.record.commit();
132              
133              
134              
135          },
136         cellclick : function (_self, row, col, e)
137          {
138               var di = _this.grid.colModel.getDataIndex(col);
139               
140               var rec = _this.grid.ds.getAt(row);
141               
142               
143               if (di == 'item_active') {
144               
145                  var nv = rec.data.item_active ? 0 : 1;
146                  new Pman.Request({
147                      mask : 'Saving',
148                      url : baseURL + '/Roo/Item',
149                      params : {
150                          item_id : rec.data.item_id,
151                          item_active : nv
152                      },
153                      success : function() {
154                          rec.set('item_active', nv);
155                      }
156                  });
157                  return;
158                  
159               
160               }
161               
162               if(di == 'itemsrc_active'){
163               
164               
165               
166          
167                  if(rec.data.itemsrc_active * 1){
168                      Roo.MessageBox.confirm("Confirm", "Are you sure this product is no longer purchased",
169                          function (res) {
170                              if(res!='yes') {
171                                  return;
172                              }
173                              rec.set('itemsrc_active', 0);
174                              rec.commit();
175                      });
176                      return;
177                  }
178                  
179                  Pman.Dialog.XtupleItem.show( { item_id : rec.data.item_id } , function() {
180                      _this.grid.footer.onClick('first');
181                 }); 
182                 return;
183                  
184              }
185               
186               _this.locgrid.footer.onClick('first');
187               
188               
189               
190               
191          },
192         celldblclick : function (_self, rowIndex, columnIndex, e)
193          {
194              var s = _this.grid.ds.getAt(rowIndex);
195              
196              Pman.Dialog.XtupleItem.show( { item_id : s.data.item_id } , function() {
197                  _this.grid.footer.onClick('first');
198             }); 
199          },
200         render : function() 
201          {
202              _this.grid = this; 
203              //_this.dialog = Pman.Dialog.FILL_IN
204              if (_this.panel.active) {
205                 this.footer.onClick('first');
206              }
207          }
208        },
209        footer : {
210         displayInfo : true,
211         displayMsg : _this._strings['aa554e9e2270df2127bfe9096f1bd9ce'] /* Displaying item{0} - {1} of {2} */,
212         emptyMsg : _this._strings['f1c3ca6cadc4a9f57a08d5f7482a3f83'] /* No item found */,
213         pageSize : 25,
214         xns : Roo,
215         '|xns' : 'Roo',
216         xtype : 'PagingToolbar',
217         items  : [
218          {
219           text : _this._strings['36c454c4130e4444e8410f11d6d998f0'] /* Tools - Upload/Download */,
220           xns : Roo.Toolbar,
221           '|xns' : 'Roo.Toolbar',
222           xtype : 'Button',
223           menu : {
224            xns : Roo.menu,
225            '|xns' : 'Roo.menu',
226            xtype : 'Menu',
227            items  : [
228             {
229              text : _this._strings['695dbdb13fad32669a68d8fec8541c7f'] /* Download Standard costs */,
230              xns : Roo.menu,
231              '|xns' : 'Roo.menu',
232              xtype : 'Item',
233              listeners : {
234               click : function (_self, e)
235                {
236                   new Pman.Download({
237                        method: 'GET',
238                        url : baseURL + '/Roo/item',
239                        params : {
240                            _costgrid : 1
241                        }
242                   });
243                }
244              }
245             },
246             {
247              text : _this._strings['70cd7e06502a63356290711ec3b11223'] /* Upload new products and costs */,
248              xns : Roo.menu,
249              '|xns' : 'Roo.menu',
250              xtype : 'Item',
251              listeners : {
252               click : function (_self, e)
253                {
254                //   Roo.MessageBox.alert("Disabled", "Can you please send Alan the test file for this - there is a problem and we need to fix it before you use this again");
255                 //  return;
256                   
257                   Pman.Dialog.Image.show(
258                       {
259                            _url : baseURL+'/Xtuple/Import/Products',
260                            timeout : 60000
261                        
262                       },
263                       function (data) {
264                            var msg = [];
265                           
266                            if (data.updated) {
267                                msg.push("Updated " + data.updated + " Products(s)");
268                            }            
269                            if (data.inserted) {
270                                msg.push("Added " + data.inserted + " Products(s)");
271                            }
272                            if (data.skipped) {
273                                msg.push("Skipped " + data.skipped);
274                            }
275                            
276                            if (!msg.length) {
277                                msg.push("No data changed");
278                            }
279                            Roo.MessageBox.alert("Notice", msg.join("\n"));
280                
281                       }
282                   );
283                }
284              }
285             },
286             {
287              xns : Roo.menu,
288              '|xns' : 'Roo.menu',
289              xtype : 'Separator'
290             },
291             {
292              hidden : (function() {
293              
294                  return baseURL.match(/hk\.php$/) ? true : false;
295              })(),
296              text : _this._strings['c2f1d503b95bf9f3aa4d775a216c5c73'] /* Sync Product Data from HK */,
297              xns : Roo.menu,
298              '|xns' : 'Roo.menu',
299              xtype : 'Item',
300              listeners : {
301               click : function (_self, e)
302                {
303                  Roo.MessageBox.progress ("Syncing Stock", "Sending");
304                  
305                  var offset = 0;
306                  
307                   function runSync() {
308                       
309                       new Pman.Request( {
310                            url : baseURL+'/Roo/Item',
311                            method : 'GET',
312                            timeout: 60000,
313                            params : {
314                                _syncFromHK : 1,
315                                offset : offset
316                            },
317                            success : function(res) {
318                                Roo.log(res);
319                                if (!res.data.total) {
320                                    Roo.MessageBox.hide();
321                                    return;
322                                }
323                                offset += res.data.limit;
324                                Roo.MessageBox.updateProgress ( offset  / res.data.total, "Done " + offset + '/' + res.data.total);
325                                runSync();
326                            }
327                            
328                        
329                       });
330                   }
331                   runSync();
332                }
333              }
334             },
335             {
336              hidden : (function() {
337              
338                  return baseURL.match(/hk\.php$/) ? true : false;
339              })(),
340              text : _this._strings['d6ea9efa48916e9563d76ddc233ebe2a'] /* Sync Product from HK (New Products Only) */,
341              xns : Roo.menu,
342              '|xns' : 'Roo.menu',
343              xtype : 'Item',
344              listeners : {
345               click : function (_self, e)
346                {
347                  Roo.MessageBox.progress ("Syncing Stock", "Sending");
348                  
349                  var offset = 0;
350                  
351                   
352                       
353                   new Pman.Request( {
354                        url : baseURL+'/Roo/Item',
355                        method : 'GET',
356                        params : {
357                            _syncFromHK : 1,
358                            _new_only : 1
359                        },
360                        success : function(res) {
361                            Roo.log(res);
362                            
363                                Roo.MessageBox.hide();
364                             _this.grid.footer.onClick('refresh');
365                            
366                             
367                        }
368                        
369                    
370                   });
371                    
372                }
373              }
374             },
375             {
376              hidden : (function() {
377              
378                  return baseURL.match(/hk\.php$/) ? true : false;
379              })(),
380              text : _this._strings['44ca8ce0e02dee5d520525ac21bcbee9'] /* Sync Product from HK (Based on Search) */,
381              xns : Roo.menu,
382              '|xns' : 'Roo.menu',
383              xtype : 'Item',
384              listeners : {
385               click : function (_self, e)
386                {
387                  Roo.MessageBox.progress ("Syncing Stock", "Sending");
388                  
389                  var offset = 0;
390                  
391                   
392                       
393                   new Pman.Request( {
394                        url : baseURL+'/Roo/Item',
395                        method : 'GET',
396                        params : {
397                            _syncFromHK : 1,
398                            item_number : _this.search.getValue()
399                        },
400                        success : function(res) {
401                            Roo.log(res);
402                            
403                                Roo.MessageBox.hide();
404                             _this.grid.footer.onClick('refresh');
405                            
406                             
407                        }
408                        
409                    
410                   });
411                    
412                }
413              }
414             }
415            ]
416           }
417          }
418         ]
419        },
420        toolbar : {
421         xns : Roo,
422         '|xns' : 'Roo',
423         xtype : 'Toolbar',
424         items  : [
425          {
426           allowBlank : true,
427           alwaysQuery : true,
428           displayField : 'charass_value',
429           editable : true,
430           emptyText : _this._strings['a9e35d03ee7f31f5bb199379a6d3547a'] /* Select Brand */,
431           forceSelection : true,
432           listWidth : 300,
433           loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
434           minChars : 2,
435           pageSize : 20,
436           qtip : _this._strings['a9e35d03ee7f31f5bb199379a6d3547a'] /* Select Brand */,
437           queryParam : 'query[charass_value]',
438           selectOnFocus : true,
439           tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
440           triggerAction : 'all',
441           width : 150,
442           xns : Roo.form,
443           '|xns' : 'Roo.form',
444           xtype : 'ComboBox',
445           listeners : {
446            render : function (_self)
447             {
448               _this.brandSel = _self;
449             },
450            select : function (combo, record, index)
451             {
452                 _this.grid.footer.onClick('first');
453             }
454           },
455           store : {
456            remoteSort : true,
457            sortInfo : { field : 'charass_value' , direction : 'ASC' },
458            xns : Roo.data,
459            '|xns' : 'Roo.data',
460            xtype : 'Store',
461            listeners : {
462             beforeload : function (_self, o)
463              {
464                  o.params = o.params || {};
465                  // staff can see all logs, other companies can only see their own.
466                  // look for all of the charass 's with the same type= eg. brand.
467                  
468                  o.params.charass_char_id_char_name = 'BRAND';
469                  o.params.charass_target_type ='I';
470                  o.params._distinct = 'charass_value';
471                      o.params._columns = 'charass_value';
472              
473              }
474            },
475            proxy : {
476             method : 'GET',
477             url : baseURL + '/Roo/Charass.php',
478             xns : Roo.data,
479             '|xns' : 'Roo.data',
480             xtype : 'HttpProxy'
481            },
482            reader : {
483             fields : [
484                 {
485                     'name': 'id',
486                     'type': 'int'
487                 },
488                 {
489                     'name': 'person_name',
490                     'type': 'string'
491                 },
492                 {
493                     'name': 'event_when',
494                     'type': 'date',
495                     'dateFormat': 'Y-m-d'
496                 },
497                 {
498                     'name': 'action',
499                     'type': 'string'
500                 },
501                 {
502                     'name': 'ipaddr',
503                     'type': 'string'
504                 },
505                 {
506                     'name': 'on_id',
507                     'type': 'int'
508                 },
509                 {
510                     'name': 'on_table',
511                     'type': 'string'
512                 },
513                 {
514                     'name': 'person_id',
515                     'type': 'int'
516                 },
517                 {
518                     'name': 'remarks',
519                     'type': 'string'
520                 },
521                 {
522                     'name': 'person_id_id',
523                     'type': 'int'
524                 },
525                 {
526                     'name': 'person_id_office_id',
527                     'type': 'int'
528                 },
529                 {
530                     'name': 'person_id_name',
531                     'type': 'string'
532                 },
533                 {
534                     'name': 'person_id_phone',
535                     'type': 'string'
536                 },
537                 {
538                     'name': 'person_id_fax',
539                     'type': 'string'
540                 },
541                 {
542                     'name': 'person_id_email',
543                     'type': 'string'
544                 },
545                 {
546                     'name': 'person_id_company_id',
547                     'type': 'int'
548                 },
549                 {
550                     'name': 'person_id_role',
551                     'type': 'string'
552                 },
553                 {
554                     'name': 'person_id_active',
555                     'type': 'int'
556                 },
557                 {
558                     'name': 'person_id_remarks',
559                     'type': 'string'
560                 },
561                 {
562                     'name': 'person_id_passwd',
563                     'type': 'string'
564                 },
565                 {
566                     'name': 'person_id_owner_id',
567                     'type': 'int'
568                 },
569                 {
570                     'name': 'person_id_lang',
571                     'type': 'string'
572                 },
573                 {
574                     'name': 'person_id_no_reset_sent',
575                     'type': 'int'
576                 },
577                 {
578                     'name': 'person_id_action_type',
579                     'type': 'string'
580                 },
581                 {
582                     'name': 'person_id_project_id',
583                     'type': 'int'
584                 },
585                 {
586                     'name': 'person_id_deleted_by',
587                     'type': 'int'
588                 },
589                 {
590                     'name': 'person_id_deleted_dt',
591                     'type': 'date'
592                 }
593             ],
594             id : 'id',
595             root : 'data',
596             totalProperty : 'total',
597             xns : Roo.data,
598             '|xns' : 'Roo.data',
599             xtype : 'JsonReader'
600            }
601           }
602          },
603          {
604           emptyText : _this._strings['9a8faafb674c03474827bcb6fcde43a3'] /* Search Product */,
605           xns : Roo.form,
606           '|xns' : 'Roo.form',
607           xtype : 'TextField',
608           listeners : {
609            render : function (_self)
610             {
611               _this.search = _self;
612             },
613            specialkey : function (_self, e)
614             {
615                 _this.grid.footer.onClick('first');
616             }
617           }
618          },
619          {
620           cls : 'x-btn-icon',
621           icon : rootURL + '/Pman/templates/images/search.gif',
622           xns : Roo.Toolbar,
623           '|xns' : 'Roo.Toolbar',
624           xtype : 'Button',
625           listeners : {
626            click : function (_self, e)
627             {
628             _this.grid.footer.onClick('first');
629             }
630           }
631          },
632          {
633           cls : 'x-btn-icon',
634           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
635           xns : Roo.Toolbar,
636           '|xns' : 'Roo.Toolbar',
637           xtype : 'Button',
638           listeners : {
639            click : function (_self, e)
640             {
641                 _this.search.setValue('');
642                 
643             
644                 
645                 _this.grid.footer.onClick('first');
646             }
647           }
648          },
649          {
650           xns : Roo.Toolbar,
651           '|xns' : 'Roo.Toolbar',
652           xtype : 'Separator'
653          },
654          {
655           enableToggle : true,
656           text : _this._strings['5bc3fd20294c17c9803942958fd7f26d'] /* Show Inactive */,
657           xns : Roo.Toolbar,
658           '|xns' : 'Roo.Toolbar',
659           xtype : 'Button',
660           listeners : {
661            render : function (_self)
662             {
663                 _this.active = _self;
664             },
665            toggle : function (_self, pressed)
666             {
667             
668                 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
669                 (function() { _this.grid.footer.onClick('first'); }).defer(100);
670             }
671           }
672          },
673          {
674           xns : Roo.Toolbar,
675           '|xns' : 'Roo.Toolbar',
676           xtype : 'Fill'
677          },
678          {
679           cls : 'x-btn-text-icon',
680           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
681           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
682           xns : Roo.Toolbar,
683           '|xns' : 'Roo.Toolbar',
684           xtype : 'Button',
685           listeners : {
686            click : function()
687             {
688             
689                Pman.Dialog.XtupleItem.show( { item_id : 0 } , function() {
690                     _this.grid.footer.onClick('first');
691                }); 
692             }
693           }
694          },
695          {
696           text : _this._strings['ee3585dbcb1e8f8826f3403c1e9d898c'] /* Rename SKU */,
697           xns : Roo.Toolbar,
698           '|xns' : 'Roo.Toolbar',
699           xtype : 'Button',
700           listeners : {
701            click : function()
702             {
703                 var s = _this.grid.selModel.getSelectedCell();
704                 if (!s) {
705                     Roo.MessageBox.alert("Error", "Select a product");
706                     return;
707                 } 
708                 var rec = _this.grid.ds.getAt(s[0]);
709                 
710                 var params = [];
711                 
712                 Roo.MessageBox.prompt(
713                     "Rename SKU", 
714                     "Warning changing SKU names affects historical data, and should only be done if you are sure that this is ok",
715                     function(r,v) {
716                         if (r != 'ok') {
717                             return;
718                             
719                         }
720                         params = {
721                             _rename_sku : v,
722                             item_id : rec.data.item_id,
723                             _check : 1
724                         }
725             
726                         change(params);
727                         
728                         return;
729                             
730                         
731             
732                     }
733                 );
734                 
735                 var change = function(params){
736                     new Pman.Request({
737                         url : baseURL + '/Roo/Item',
738                         mask : "Renaming",
739                         method : 'POST',
740                         params : params,
741                         success : function(res) {
742                             Roo.log(res);
743                             _this.grid.footer.onClick('refresh');
744                             if(typeof(res.data) == 'string'){
745                                 Roo.MessageBox.alert("Notice", 'SKU has been renamed');
746                                 return
747                             }
748                             var offices = [];
749                             Roo.each(res.data, function(o){
750                                 offices.push(Pman.Xtuple.offices[o]);
751                             })
752                             Roo.MessageBox.alert("Notice", 'SKU has been renamed in ' + offices.join(", "));
753                             
754                         },
755                         failure : function(res) {
756                             Roo.log(res);
757                             try {
758                                 if (res.errors.confirm.length) {
759                                     var offices = [];
760                                     Roo.each(res.errors.confirm, function(o){
761                                         offices.push(Pman.Xtuple.offices[o]);
762                                     })
763                                     Roo.MessageBox.confirm(
764                                         "Confirm", 
765                                         " Do you want to change the name in " + offices.join(", ") + "?",
766                                         function(x) {
767                                             if (x != 'yes') {
768                                                 Roo.MessageBox.alert("Notice", 'SKU was not changed');
769                                                 return;
770                                             }
771                                             delete params['_check'];
772                                             params._can_change_sku = 1;
773                                             change(params);
774                                         }
775                                     );
776                                     return;
777                                 }
778                             } catch(e) { }
779                             Roo.MessageBox.alert("Error", res.errorMsg);
780                             
781                         }
782                     });
783                 }
784                
785             }
786           }
787          },
788          {
789           xns : Roo.Toolbar,
790           '|xns' : 'Roo.Toolbar',
791           xtype : 'Separator'
792          },
793          {
794           text : _this._strings['7fee866379427143414dd7a72e56414b'] /* Report start : */,
795           xns : Roo.Toolbar,
796           '|xns' : 'Roo.Toolbar',
797           xtype : 'TextItem'
798          },
799          {
800           format : 'd/M/Y',
801           useIso : true,
802           value : (function() { return (new Date()).format('Y') + '-01-01'; })(),
803           xns : Roo.form,
804           '|xns' : 'Roo.form',
805           xtype : 'DateField',
806           listeners : {
807            render : function (_self)
808             {
809                 _this.dateFrom = _self;
810             }
811           }
812          },
813          {
814           allowBlank : false,
815           displayField : 'fname',
816           editable : false,
817           fieldLabel : _this._strings['ec53a8c4f07baed5d8825072c89799be'] /* Status */,
818           hiddenName : 'cm_status',
819           listWidth : 200,
820           mode : 'local',
821           name : 'cm_status_name',
822           triggerAction : 'all',
823           value : 12,
824           valueField : 'ftype',
825           width : 150,
826           xns : Roo.form,
827           '|xns' : 'Roo.form',
828           xtype : 'ComboBox',
829           listeners : {
830            render : function (_self)
831             {
832               _this.datespan  = _self;
833             }
834           },
835           store : {
836            data : [ 
837                [ '1', "Single Month Sales"],
838                [ '3', "Quarter Sales"],
839                [ '6', "Half year Sales"] ,
840                [ '12', "Full Year Sales"] 
841            ],
842            fields : [  'ftype', 'fname'],
843            xns : Roo.data,
844            '|xns' : 'Roo.data',
845            xtype : 'SimpleStore'
846           }
847          },
848          {
849           text : _this._strings['e924991fc4c883bc237e69efe884d674'] /* Download Sales Report */,
850           xns : Roo.Toolbar,
851           '|xns' : 'Roo.Toolbar',
852           xtype : 'Button',
853           listeners : {
854            click : function (_self, e)
855             {
856                 if (!_this.brandSel.getValue().length) {
857                     Roo.MessageBox.alert("Error", "Select a brand to download");
858                     return;
859                 }
860             
861                 new Pman.Download({
862                     url : baseURL + '/Xtuple/Reports/SalesByCountryItemYear',
863                     params: { 
864                         date_from : _this.dateFrom.getValue(),
865                         brand : _this.brandSel.getValue(),
866                         span : _this.datespan.getValue()
867                     }
868                 });
869                     
870             
871             }
872           }
873          }
874         ]
875        },
876        dataSource : {
877         remoteSort : true,
878         sortInfo : { field : 'item_number', direction: 'ASC' },
879         xns : Roo.data,
880         '|xns' : 'Roo.data',
881         xtype : 'Store',
882         listeners : {
883          beforeload : function (_self, o)
884           {
885             o.params._with_prodcat = 1;
886             o.params._with_char = 1;
887             o.params._with_itemsrc_active = 1;
888             o.params._with_last_purchase_price = 1;
889             o.params._with_image = 1;
890             var s = _this.search.getValue();
891             if (s.length) {
892               o.params['query[number_or_name]'] = s;
893             }
894             if (!_this.active.pressed) {
895               o.params.item_active = 1;
896             }
897             if (_this.brandSel.getValue().length) {
898               o.params._with_brand = _this.brandSel.getValue()
899             }
900             
901             o.params._with_stock_balance = 1;
902           },
903          load : function (_self, records, options)
904           {
905           
906               var cm = _this.grid.getColumnModel();
907               if(records.length){
908                   cm.setColumnHeader(cm.getIndexByDataIndex('item_stock_balance'),records[0].data.default_location_name);
909               }
910           },
911          update : function (_self, record, operation)
912           {
913               if(operation != 'commit'){
914                   return;
915               }
916               
917               var nv  = record.data.itemsrc_active ? 0 : 1;
918               new Pman.Request({
919                   mask : 'Saving',
920                   url : baseURL + '/Roo/Itemsrc',
921                   params : {
922                       _update_by_item : 1,
923                       item_id : record.data.item_id,
924                       itemsrc_active : nv
925                   },
926                   success : function(res) {
927                       record.set('itemsrc_active', nv);
928                   }
929               });
930           }
931         },
932         proxy : {
933          method : 'GET',
934          url : baseURL + '/Roo/item.php',
935          xns : Roo.data,
936          '|xns' : 'Roo.data',
937          xtype : 'HttpProxy'
938         },
939         reader : {
940          fields : [
941              {
942                  'name': 'item_id',
943                  'type': 'int'
944              },
945              {
946                  'name': 'item_number',
947                  'type': 'string'
948              },
949              {
950                  'name': 'item_descrip1',
951                  'type': 'string'
952              },
953              {
954                  'name': 'item_descrip2',
955                  'type': 'string'
956              },
957              {
958                  'name': 'item_classcode_id',
959                  'type': 'int'
960              },
961              {
962                  'name': 'item_picklist',
963                  'type': 'int'
964              },
965              {
966                  'name': 'item_comments',
967                  'type': 'string'
968              },
969              {
970                  'name': 'item_sold',
971                  'type': 'int'
972              },
973              {
974                  'name': 'item_fractional',
975                  'type': 'int'
976              },
977              {
978                  'name': 'item_active',
979                  'type': 'int'
980              },
981              {
982                  'name': 'item_type',
983                  'type': 'string'
984              },
985              {
986                  'name': 'item_prodweight',
987                  'type': 'float'
988              },
989              {
990                  'name': 'item_packweight',
991                  'type': 'float'
992              },
993              {
994                  'name': 'item_prodcat_id',
995                  'type': 'int'
996              },
997              {
998                  'name': 'item_exclusive',
999                  'type': 'int'
1000              },
1001              {
1002                  'name': 'item_listprice',
1003                  'type': 'float'
1004              },
1005              {
1006                  'name': 'item_config',
1007                  'type': 'int'
1008              },
1009              {
1010                  'name': 'item_extdescrip',
1011                  'type': 'string'
1012              },
1013              {
1014                  'name': 'item_upccode',
1015                  'type': 'string'
1016              },
1017              {
1018                  'name': 'item_maxcost',
1019                  'type': 'float'
1020              },
1021              {
1022                  'name': 'item_inv_uom_id',
1023                  'type': 'int'
1024              },
1025              {
1026                  'name': 'item_price_uom_id',
1027                  'type': 'int'
1028              },
1029              {
1030                  'name': 'item_warrdays',
1031                  'type': 'int'
1032              },
1033              {
1034                  'name': 'item_freightclass_id',
1035                  'type': 'int'
1036              },
1037              {
1038                  'name': 'item_tax_recoverable',
1039                  'type': 'int'
1040              },
1041              {
1042                  'name': 'item_price_uom_id_uom_id',
1043                  'type': 'int'
1044              },
1045              {
1046                  'name': 'item_price_uom_id_uom_name',
1047                  'type': 'string'
1048              },
1049              {
1050                  'name': 'item_price_uom_id_uom_descrip',
1051                  'type': 'string'
1052              },
1053              {
1054                  'name': 'item_price_uom_id_uom_item_weight',
1055                  'type': 'int'
1056              },
1057              {
1058                  'name': 'item_inv_uom_id_uom_id',
1059                  'type': 'int'
1060              },
1061              {
1062                  'name': 'item_inv_uom_id_uom_name',
1063                  'type': 'string'
1064              },
1065              {
1066                  'name': 'item_inv_uom_id_uom_descrip',
1067                  'type': 'string'
1068              },
1069              {
1070                  'name': 'item_inv_uom_id_uom_item_weight',
1071                  'type': 'int'
1072              },
1073              {
1074                  'name': 'item_freightclass_id_freightclass_id',
1075                  'type': 'int'
1076              },
1077              {
1078                  'name': 'item_freightclass_id_freightclass_code',
1079                  'type': 'string'
1080              },
1081              {
1082                  'name': 'item_freightclass_id_freightclass_descrip',
1083                  'type': 'string'
1084              },
1085              {
1086                  'name': 'item_classcode_id_classcode_id',
1087                  'type': 'int'
1088              },
1089              {
1090                  'name': 'item_classcode_id_classcode_code',
1091                  'type': 'string'
1092              },
1093              {
1094                  'name': 'item_classcode_id_classcode_descrip',
1095                  'type': 'string'
1096              },
1097              {
1098                  'name': 'item_classcode_id_classcode_mfg',
1099                  'type': 'int'
1100              },
1101              {
1102                  'name': 'item_classcode_id_classcode_creator',
1103                  'type': 'string'
1104              },
1105              {
1106                  'name': 'item_classcode_id_classcode_created',
1107                  'type': 'date'
1108              },
1109              {
1110                  'name': 'item_classcode_id_classcode_modifier',
1111                  'type': 'string'
1112              },
1113              {
1114                  'name': 'item_classcode_id_classcode_modified',
1115                  'type': 'date'
1116              },
1117              {
1118                  'name': 'item_classcode_id_classcode_type',
1119                  'type': 'string'
1120              }
1121          ],
1122          id : 'id',
1123          root : 'data',
1124          totalProperty : 'total',
1125          xns : Roo.data,
1126          '|xns' : 'Roo.data',
1127          xtype : 'JsonReader'
1128         }
1129        },
1130        colModel : [
1131         {
1132          dataIndex : 'item_image_id',
1133          header : _this._strings['be53a0541a6d36f6ecb879fa2c584b08'] /* Image */,
1134          renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/50/{1}/{2}" height="50">', baseURL, v, r.data.item_image_filename); },
1135          sortable : false,
1136          width : 150,
1137          xns : Roo.grid,
1138          '|xns' : 'Roo.grid',
1139          xtype : 'ColumnModel'
1140         },
1141         {
1142          dataIndex : 'item_char_brand',
1143          header : _this._strings['1be6f9eb563f3bf85c78b4219bf09de9'] /* Brand */,
1144          renderer : function(v) { return String.format('{0}', v); },
1145          sortable : true,
1146          width : 100,
1147          xns : Roo.grid,
1148          '|xns' : 'Roo.grid',
1149          xtype : 'ColumnModel',
1150          editor : {
1151           xns : Roo.grid,
1152           '|xns' : 'Roo.grid',
1153           xtype : 'GridEditor',
1154           field : {
1155            allowBlank : true,
1156            alwaysQuery : true,
1157            displayField : 'charass_value',
1158            editable : true,
1159            forceSelection : false,
1160            listWidth : 300,
1161            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1162            minChars : 2,
1163            pageSize : 20,
1164            qtip : _this._strings['a9e35d03ee7f31f5bb199379a6d3547a'] /* Select Brand */,
1165            queryParam : 'query[charass_value]',
1166            selectOnFocus : true,
1167            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
1168            triggerAction : 'all',
1169            width : 150,
1170            xns : Roo.form,
1171            '|xns' : 'Roo.form',
1172            xtype : 'ComboBox',
1173            store : {
1174             remoteSort : true,
1175             sortInfo : { field : 'charass_value' , direction : 'ASC' },
1176             xns : Roo.data,
1177             '|xns' : 'Roo.data',
1178             xtype : 'Store',
1179             listeners : {
1180              beforeload : function (_self, o)
1181               {
1182                   o.params = o.params || {};
1183                   // staff can see all logs, other companies can only see their own.
1184                   // look for all of the charass 's with the same type= eg. brand.
1185                   
1186                   o.params.charass_char_id_char_name = 'BRAND';
1187                   o.params.charass_target_type ='I';
1188                   o.params._distinct = 'charass_value';
1189                       o.params._columns = 'charass_value';
1190               
1191               }
1192             },
1193             proxy : {
1194              method : 'GET',
1195              url : baseURL + '/Roo/Charass.php',
1196              xns : Roo.data,
1197              '|xns' : 'Roo.data',
1198              xtype : 'HttpProxy'
1199             },
1200             reader : {
1201              fields : [
1202                  {
1203                      'name': 'id',
1204                      'type': 'int'
1205                  },
1206                  {
1207                      'name': 'person_name',
1208                      'type': 'string'
1209                  },
1210                  {
1211                      'name': 'event_when',
1212                      'type': 'date',
1213                      'dateFormat': 'Y-m-d'
1214                  },
1215                  {
1216                      'name': 'action',
1217                      'type': 'string'
1218                  },
1219                  {
1220                      'name': 'ipaddr',
1221                      'type': 'string'
1222                  },
1223                  {
1224                      'name': 'on_id',
1225                      'type': 'int'
1226                  },
1227                  {
1228                      'name': 'on_table',
1229                      'type': 'string'
1230                  },
1231                  {
1232                      'name': 'person_id',
1233                      'type': 'int'
1234                  },
1235                  {
1236                      'name': 'remarks',
1237                      'type': 'string'
1238                  },
1239                  {
1240                      'name': 'person_id_id',
1241                      'type': 'int'
1242                  },
1243                  {
1244                      'name': 'person_id_office_id',
1245                      'type': 'int'
1246                  },
1247                  {
1248                      'name': 'person_id_name',
1249                      'type': 'string'
1250                  },
1251                  {
1252                      'name': 'person_id_phone',
1253                      'type': 'string'
1254                  },
1255                  {
1256                      'name': 'person_id_fax',
1257                      'type': 'string'
1258                  },
1259                  {
1260                      'name': 'person_id_email',
1261                      'type': 'string'
1262                  },
1263                  {
1264                      'name': 'person_id_company_id',
1265                      'type': 'int'
1266                  },
1267                  {
1268                      'name': 'person_id_role',
1269                      'type': 'string'
1270                  },
1271                  {
1272                      'name': 'person_id_active',
1273                      'type': 'int'
1274                  },
1275                  {
1276                      'name': 'person_id_remarks',
1277                      'type': 'string'
1278                  },
1279                  {
1280                      'name': 'person_id_passwd',
1281                      'type': 'string'
1282                  },
1283                  {
1284                      'name': 'person_id_owner_id',
1285                      'type': 'int'
1286                  },
1287                  {
1288                      'name': 'person_id_lang',
1289                      'type': 'string'
1290                  },
1291                  {
1292                      'name': 'person_id_no_reset_sent',
1293                      'type': 'int'
1294                  },
1295                  {
1296                      'name': 'person_id_action_type',
1297                      'type': 'string'
1298                  },
1299                  {
1300                      'name': 'person_id_project_id',
1301                      'type': 'int'
1302                  },
1303                  {
1304                      'name': 'person_id_deleted_by',
1305                      'type': 'int'
1306                  },
1307                  {
1308                      'name': 'person_id_deleted_dt',
1309                      'type': 'date'
1310                  }
1311              ],
1312              id : 'id',
1313              root : 'data',
1314              totalProperty : 'total',
1315              xns : Roo.data,
1316              '|xns' : 'Roo.data',
1317              xtype : 'JsonReader'
1318             }
1319            }
1320           }
1321          }
1322         },
1323         {
1324          dataIndex : 'item_char_productgroup',
1325          header : _this._strings['c6ca371871d835c79c8654b5cd788cc7'] /* Product Group */,
1326          renderer : function(v) { return String.format('{0}', v); },
1327          sortable : true,
1328          width : 100,
1329          xns : Roo.grid,
1330          '|xns' : 'Roo.grid',
1331          xtype : 'ColumnModel',
1332          editor : {
1333           xns : Roo.grid,
1334           '|xns' : 'Roo.grid',
1335           xtype : 'GridEditor',
1336           field : {
1337            allowBlank : true,
1338            alwaysQuery : true,
1339            displayField : 'charass_value',
1340            editable : true,
1341            forceSelection : false,
1342            listWidth : 300,
1343            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1344            minChars : 2,
1345            pageSize : 20,
1346            qtip : _this._strings['a9e35d03ee7f31f5bb199379a6d3547a'] /* Select Brand */,
1347            queryParam : 'query[charass_value]',
1348            selectOnFocus : true,
1349            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{charass_value}</b> </div>',
1350            triggerAction : 'all',
1351            width : 150,
1352            xns : Roo.form,
1353            '|xns' : 'Roo.form',
1354            xtype : 'ComboBox',
1355            store : {
1356             remoteSort : true,
1357             sortInfo : { field : 'charass_value' , direction : 'ASC' },
1358             xns : Roo.data,
1359             '|xns' : 'Roo.data',
1360             xtype : 'Store',
1361             listeners : {
1362              beforeload : function (_self, o)
1363               {
1364                   o.params = o.params || {};
1365                   // staff can see all logs, other companies can only see their own.
1366                   // look for all of the charass 's with the same type= eg. brand.
1367                   
1368                   o.params.charass_char_id_char_name = 'PRODUCTGROUP';
1369                   o.params.charass_target_type ='I';
1370                   o.params._distinct = 'charass_value';
1371                       o.params._columns = 'charass_value';    
1372               }
1373             },
1374             proxy : {
1375              method : 'GET',
1376              url : baseURL + '/Roo/Charass.php',
1377              xns : Roo.data,
1378              '|xns' : 'Roo.data',
1379              xtype : 'HttpProxy'
1380             },
1381             reader : {
1382              fields : [
1383                  {
1384                      'name': 'id',
1385                      'type': 'int'
1386                  },
1387                  {
1388                      'name': 'person_name',
1389                      'type': 'string'
1390                  },
1391                  {
1392                      'name': 'event_when',
1393                      'type': 'date',
1394                      'dateFormat': 'Y-m-d'
1395                  },
1396                  {
1397                      'name': 'action',
1398                      'type': 'string'
1399                  },
1400                  {
1401                      'name': 'ipaddr',
1402                      'type': 'string'
1403                  },
1404                  {
1405                      'name': 'on_id',
1406                      'type': 'int'
1407                  },
1408                  {
1409                      'name': 'on_table',
1410                      'type': 'string'
1411                  },
1412                  {
1413                      'name': 'person_id',
1414                      'type': 'int'
1415                  },
1416                  {
1417                      'name': 'remarks',
1418                      'type': 'string'
1419                  },
1420                  {
1421                      'name': 'person_id_id',
1422                      'type': 'int'
1423                  },
1424                  {
1425                      'name': 'person_id_office_id',
1426                      'type': 'int'
1427                  },
1428                  {
1429                      'name': 'person_id_name',
1430                      'type': 'string'
1431                  },
1432                  {
1433                      'name': 'person_id_phone',
1434                      'type': 'string'
1435                  },
1436                  {
1437                      'name': 'person_id_fax',
1438                      'type': 'string'
1439                  },
1440                  {
1441                      'name': 'person_id_email',
1442                      'type': 'string'
1443                  },
1444                  {
1445                      'name': 'person_id_company_id',
1446                      'type': 'int'
1447                  },
1448                  {
1449                      'name': 'person_id_role',
1450                      'type': 'string'
1451                  },
1452                  {
1453                      'name': 'person_id_active',
1454                      'type': 'int'
1455                  },
1456                  {
1457                      'name': 'person_id_remarks',
1458                      'type': 'string'
1459                  },
1460                  {
1461                      'name': 'person_id_passwd',
1462                      'type': 'string'
1463                  },
1464                  {
1465                      'name': 'person_id_owner_id',
1466                      'type': 'int'
1467                  },
1468                  {
1469                      'name': 'person_id_lang',
1470                      'type': 'string'
1471                  },
1472                  {
1473                      'name': 'person_id_no_reset_sent',
1474                      'type': 'int'
1475                  },
1476                  {
1477                      'name': 'person_id_action_type',
1478                      'type': 'string'
1479                  },
1480                  {
1481                      'name': 'person_id_project_id',
1482                      'type': 'int'
1483                  },
1484                  {
1485                      'name': 'person_id_deleted_by',
1486                      'type': 'int'
1487                  },
1488                  {
1489                      'name': 'person_id_deleted_dt',
1490                      'type': 'date'
1491                  }
1492              ],
1493              id : 'id',
1494              root : 'data',
1495              totalProperty : 'total',
1496              xns : Roo.data,
1497              '|xns' : 'Roo.data',
1498              xtype : 'JsonReader'
1499             }
1500            }
1501           }
1502          }
1503         },
1504         {
1505          dataIndex : 'item_number',
1506          header : _this._strings['b2ee912b91d69b435159c7c3f6df7f5f'] /* Number */,
1507          renderer : function(v) { return String.format('<B>{0}</B>', v); },
1508          sortable : true,
1509          width : 100,
1510          xns : Roo.grid,
1511          '|xns' : 'Roo.grid',
1512          xtype : 'ColumnModel'
1513         },
1514         {
1515          dataIndex : 'item_char_pickface_location',
1516          header : _this._strings['d8ab3576a67fe0cc175ee77d57d0fd85'] /* Pickface */,
1517          renderer : function(v) { return String.format('{0}', v); },
1518          sortable : true,
1519          width : 100,
1520          xns : Roo.grid,
1521          '|xns' : 'Roo.grid',
1522          xtype : 'ColumnModel',
1523          editor : {
1524           xns : Roo.grid,
1525           '|xns' : 'Roo.grid',
1526           xtype : 'GridEditor',
1527           field : {
1528            xns : Roo.form,
1529            '|xns' : 'Roo.form',
1530            xtype : 'TextField'
1531           }
1532          }
1533         },
1534         {
1535          dataIndex : 'item_char_pallet_location',
1536          header : _this._strings['fe78f3efbfa84d8485d589031596c5b8'] /* Pallet */,
1537          renderer : function(v) { return String.format('{0}', v); },
1538          sortable : true,
1539          width : 100,
1540          xns : Roo.grid,
1541          '|xns' : 'Roo.grid',
1542          xtype : 'ColumnModel',
1543          editor : {
1544           xns : Roo.grid,
1545           '|xns' : 'Roo.grid',
1546           xtype : 'GridEditor',
1547           field : {
1548            xns : Roo.form,
1549            '|xns' : 'Roo.form',
1550            xtype : 'TextField'
1551           }
1552          }
1553         },
1554         {
1555          dataIndex : 'item_descrip1',
1556          header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
1557          renderer : function(v) { return String.format('{0}', v); },
1558          sortable : true,
1559          width : 200,
1560          xns : Roo.grid,
1561          '|xns' : 'Roo.grid',
1562          xtype : 'ColumnModel'
1563         },
1564         {
1565          dataIndex : 'itemsrc_active',
1566          header : _this._strings['ce4ee01637f4279d02d0f232459dc9a4'] /* Purchased */,
1567          renderer : function(v) {  
1568              var state = v * 1 > 0 ?  '-checked' : '';
1569          
1570              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1571                          
1572           },
1573          sortable : true,
1574          width : 55,
1575          xns : Roo.grid,
1576          '|xns' : 'Roo.grid',
1577          xtype : 'ColumnModel'
1578         },
1579         {
1580          dataIndex : 'item_sold',
1581          header : _this._strings['41e902bb1b2db625736ede3bacc41fe0'] /* is Sold? */,
1582          renderer : function(v) {  
1583              var state = v * 1 > 0 ?  '-checked' : '';
1584          
1585              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1586                          
1587           },
1588          sortable : true,
1589          width : 50,
1590          xns : Roo.grid,
1591          '|xns' : 'Roo.grid',
1592          xtype : 'ColumnModel'
1593         },
1594         {
1595          dataIndex : 'item_active',
1596          header : _this._strings['68f43fdcf074903d65da764642a4b968'] /* is Active? */,
1597          renderer : function(v) {  
1598              var state = v * 1 > 0 ?  '-checked' : '';
1599          
1600              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1601                          
1602           },
1603          sortable : true,
1604          width : 50,
1605          xns : Roo.grid,
1606          '|xns' : 'Roo.grid',
1607          xtype : 'ColumnModel'
1608         },
1609         {
1610          align : 'right',
1611          dataIndex : 'last_purchase_price',
1612          header : _this._strings['750587d31c68779e7f615c190a9dc23f'] /* Last purchase price */,
1613          renderer : function(v,x,r) {
1614          
1615               return String.format('{0}{1}', r.data.last_purchase_price_curr_name, Roo.util.Format.number(v,2)) ; 
1616               
1617           },
1618          width : 120,
1619          xns : Roo.grid,
1620          '|xns' : 'Roo.grid',
1621          xtype : 'ColumnModel'
1622         },
1623         {
1624          dataIndex : 'item_prodcat_id_prodcat_code',
1625          header : _this._strings['89217b1527e14cced20e78111a8f5027'] /* Item prodcat */,
1626          renderer : function(v,x,r) { 
1627              return String.format('{0}/{1}', r.data.item_type, v); 
1628              },
1629          width : 100,
1630          xns : Roo.grid,
1631          '|xns' : 'Roo.grid',
1632          xtype : 'ColumnModel'
1633         },
1634         {
1635          align : 'right',
1636          dataIndex : 'item_actcost',
1637          header : _this._strings['20b4f77bd00b4f63a49ec8e08f3bf6a6'] /* Cost */,
1638          renderer : function(v,x,r) {
1639          
1640               return String.format('{0}{1}', r.data.item_curr_name, Roo.util.Format.number(v,2)) ; 
1641               
1642           },
1643          width : 75,
1644          xns : Roo.grid,
1645          '|xns' : 'Roo.grid',
1646          xtype : 'ColumnModel'
1647         },
1648         {
1649          align : 'right',
1650          dataIndex : 'item_base_cost',
1651          header : _this._strings['35be52be39d3efcd0cd2b3721fc3c298'] /* Cost (base) */,
1652          renderer : function(v,x,r) {
1653          
1654               return String.format('{0}{1}', r.data.item_base_curr, Roo.util.Format.number(v,2)) ; 
1655               
1656           },
1657          width : 75,
1658          xns : Roo.grid,
1659          '|xns' : 'Roo.grid',
1660          xtype : 'ColumnModel'
1661         },
1662         {
1663          align : 'right',
1664          dataIndex : 'item_stock_balance',
1665          header : _this._strings['99a808d8d16122d70e44bd7f709d30fb'] /* Balance */,
1666          renderer : function(v) { return String.format('{0}', v ? parseInt( v) : ''); },
1667          width : 100,
1668          xns : Roo.grid,
1669          '|xns' : 'Roo.grid',
1670          xtype : 'ColumnModel'
1671         }
1672        ]
1673       }
1674      },
1675      {
1676       background : true,
1677       fitContainer : true,
1678       fitToframe : true,
1679       region : 'east',
1680       tableName : 'itemloc',
1681       title : _this._strings['759d259249621c817551c5fe726d5c57'] /* itemloc */,
1682       xns : Roo,
1683       '|xns' : 'Roo',
1684       xtype : 'GridPanel',
1685       listeners : {
1686        activate : function() {
1687             _this.locpanel = this;
1688          
1689         }
1690       },
1691       grid : {
1692        autoExpandColumn : 'location_name',
1693        loadMask : true,
1694        xns : Roo.grid,
1695        '|xns' : 'Roo.grid',
1696        xtype : 'Grid',
1697        listeners : {
1698         render : function() 
1699          {
1700              _this.locgrid = this; 
1701              //_this.dialog = Pman.Dialog.FILL_IN
1702              
1703          },
1704         rowdblclick : function (_self, rowIndex, e)
1705          {
1706              if (!_this.dialog) return;
1707              _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
1708                  _this.grid.footer.onClick('first');
1709              }); 
1710          }
1711        },
1712        footer : {
1713         displayInfo : true,
1714         displayMsg : _this._strings['19029645d5286771ac708d1bcd118bf4'] /* Displaying itemloc{0} - {1} of {2} */,
1715         emptyMsg : _this._strings['2cfd827c6e37453fe1ddde82a5bd9474'] /* No itemloc found */,
1716         pageSize : 25,
1717         xns : Roo,
1718         '|xns' : 'Roo',
1719         xtype : 'PagingToolbar'
1720        },
1721        dataSource : {
1722         remoteSort : true,
1723         sortInfo : { field : 'location_name', direction: 'ASC' },
1724         xns : Roo.data,
1725         '|xns' : 'Roo.data',
1726         xtype : 'Store',
1727         listeners : {
1728          beforeload : function (_self, o)
1729           {
1730               var sel = _this.grid.selModel.getSelectedCell();
1731               if (!sel) {
1732                   this.removeAll();
1733                   return false;
1734               }
1735               var rec = _this.grid.ds.getAt(sel[0]);
1736               o.params._stock_for_item_id = rec.data.item_id;
1737               //o.params['!itemloc_qty'] = 0;
1738               
1739               
1740           }
1741         },
1742         proxy : {
1743          method : 'GET',
1744          url : baseURL + '/Roo/location.php',
1745          xns : Roo.data,
1746          '|xns' : 'Roo.data',
1747          xtype : 'HttpProxy'
1748         },
1749         reader : {
1750          fields : [
1751              {
1752                  'name': 'itemloc_id',
1753                  'type': 'int'
1754              },
1755              {
1756                  'name': 'itemloc_itemsite_id',
1757                  'type': 'int'
1758              },
1759              {
1760                  'name': 'itemloc_location_id',
1761                  'type': 'int'
1762              },
1763              {
1764                  'name': 'itemloc_qty',
1765                  'type': 'float'
1766              },
1767              {
1768                  'name': 'itemloc_expiration',
1769                  'type': 'date',
1770                  'dateFormat': 'Y-m-d'
1771              },
1772              {
1773                  'name': 'itemloc_consolflag',
1774                  'type': 'int'
1775              },
1776              {
1777                  'name': 'itemloc_ls_id',
1778                  'type': 'int'
1779              },
1780              {
1781                  'name': 'itemloc_warrpurc',
1782                  'type': 'date',
1783                  'dateFormat': 'Y-m-d'
1784              }
1785          ],
1786          id : 'id',
1787          root : 'data',
1788          totalProperty : 'total',
1789          xns : Roo.data,
1790          '|xns' : 'Roo.data',
1791          xtype : 'JsonReader'
1792         }
1793        },
1794        colModel : [
1795         {
1796          dataIndex : 'location_name',
1797          header : _this._strings['ce5bf551379459c1c61d2a204061c455'] /* Location */,
1798          renderer : function(v) { return String.format('{0}', v); },
1799          width : 75,
1800          xns : Roo.grid,
1801          '|xns' : 'Roo.grid',
1802          xtype : 'ColumnModel'
1803         },
1804         {
1805          dataIndex : 'itemloc_realqty',
1806          header : _this._strings['156567f65fc207d39cadbf045687c521'] /* Itemloc qty */,
1807          renderer : function(v) { return String.format('{0}', v*1 ? (v*1).toFixed(0) : ''); },
1808          width : 75,
1809          xns : Roo.grid,
1810          '|xns' : 'Roo.grid',
1811          xtype : 'ColumnModel'
1812         }
1813        ]
1814       }
1815      }
1816     ]
1817    }
1818   };  }
1819 });