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