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