Pman.Dialog.XtupleItem.bjs
[Pman.Xtuple] / Pman.Dialog.XtupleItem.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.XtupleItem = {
8
9     dialog : false,
10     callback:  false,
11
12     show : function(data, cb)
13     {
14         if (!this.dialog) {
15             this.create();
16         }
17
18         this.callback = cb;
19         this.data = data;
20         this.dialog.show(this.data._el);
21         if (this.form) {
22            this.form.reset();
23            this.form.setValues(data);
24            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25         }
26
27     },
28
29     create : function()
30     {
31         var _this = this;
32         this.dialog = Roo.factory({
33             center : {
34                 '|xns' : 'Roo',
35                 alwaysShowTabs : true,
36                 xtype : 'LayoutRegion',
37                 tabPosition : 'top',
38                 xns : Roo
39             },
40             '|xns' : 'Roo',
41             modal : true,
42             collapsible : false,
43             title : "Edit / Create item",
44             xtype : 'LayoutDialog',
45             width : 800,
46             xns : Roo,
47             closable : false,
48             resizable : false,
49             height : 550,
50             buttons : [
51                  {
52                         '|xns' : 'Roo',
53                         text : "Cancel",
54                         xtype : 'Button',
55                         xns : Roo,
56                         listeners : {
57                                 click : function (_self, e)
58                                    {
59                                        _this.dialog.hide();
60                                    }
61                         }
62                     },
63 {
64                         '|xns' : 'Roo',
65                         text : "Save",
66                         xtype : 'Button',
67                         xns : Roo,
68                         listeners : {
69                                 render : function (_self)
70                                    {
71                                        _this.saveBtn = this;
72                                    },
73                                 click : function (_self, e)
74                                    {
75                                        // do some checks?
76                                         
77                                        
78                                      //  _this.dialog.el.mask("Saving");
79                                        _this.form.doAction("submit");
80                                    
81                                    }
82                         }
83                     }
84             ],
85             listeners : {
86                 show : function (_self)
87                    {
88                         _this.dialog.layout.getRegion('center').showPanel(0);
89                    }
90             },
91             items : [
92                 {
93                     '|xns' : 'Roo',
94                     region : 'center',
95                     title : "Detail",
96                     xtype : 'ContentPanel',
97                     xns : Roo,
98                     items : [
99                         {
100                             '|xns' : 'Roo.form',
101                             url : baseURL + '/Roo/item.php',
102                             method : 'POST',
103                             style : 'margin:10px;',
104                             xtype : 'Form',
105                             labelWidth : 120,
106                             xns : Roo.form,
107                             listeners : {
108                                 actioncomplete : function(_self,action)
109                                    {
110                                        if (action.type == 'setdata') {
111                                           _this.form.findField('item_number').el.dom.readOnly = true;
112                                           _this.form.findField('item_type').disabled = true; 
113                                           
114                                           if(_this.data.item_id * 1 > 0){
115                                                
116                                                this.load({ 
117                                                    method: 'GET', 
118                                                    params: {
119                                                         '_id' : _this.data.item_id,
120                                                         '_with_itemsite' : 1,
121                                                         '_with_itemcost' : 1,
122                                                         '_with_prodcat' : 1 ,
123                                                         '_with_salesaccnt' : 1 
124                                                    }
125                                                });
126                                                return;
127                                           }
128                                           // if it's new..
129                                           _this.form.findField('item_number').el.dom.readOnly = false;
130                                           _this.form.findField('item_type').disabled = false; 
131                                           _this.form.findField('item_salesaccnt').setValue('');
132                                           
133                                           return;
134                                        }
135                                        if (action.type == 'load') {
136                                           _this.form.findField('item_type').showHide();
137                                            return;
138                                        }
139                                        if (action.type =='submit') {
140                                        
141                                            var id = _this.form.findField('item_id').getValue() * 1;
142                                            if (id < 1) {
143                                            
144                                                this.load({ 
145                                                    method: 'GET', 
146                                                    params: {
147                                                         '_id' : action.result.data.item_id,
148                                                         '_with_itemsite' : 1,
149                                                         '_with_itemcost' : 1,
150                                                         '_with_prodcat' : 1 ,
151                                                         '_with_salesaccnt' : 1 
152                                                    }
153                                                });
154                                                return;
155                                            }
156                                            _this.dialog.hide();
157                                        
158                                             if (_this.callback) {
159                                                _this.callback.call(_this, _this.form.getValues());
160                                             }
161                                             _this.form.reset();
162                                             return;
163                                        }
164                                    },
165                                 rendered : function (form)
166                                    {
167                                        _this.form= form;
168                                    }
169                             },
170                             items : [
171                                 {
172                                     '|xns' : 'Roo.form',
173                                     fieldLabel : 'SKU',
174                                     xtype : 'TextField',
175                                     allowBlank : false,
176                                     width : 200,
177                                     xns : Roo.form,
178                                     name : 'item_number'
179                                 },
180                                 {
181                                     '|xns' : 'Roo.form',
182                                     fieldLabel : 'Description',
183                                     xtype : 'TextField',
184                                     width : 400,
185                                     xns : Roo.form,
186                                     name : 'item_descrip1'
187                                 },
188                                 {
189                                     '|xns' : 'Roo.form',
190                                     fieldLabel : 'Description (2)',
191                                     xtype : 'TextField',
192                                     width : 400,
193                                     xns : Roo.form,
194                                     name : 'item_descrip2'
195                                 },
196                                 {
197                                     '|xns' : 'Roo.form',
198                                     xtype : 'Column',
199                                     labelWidth : 120,
200                                     xns : Roo.form,
201                                     items : [
202                                         {
203                                             store : {
204                                                 '|xns' : 'Roo.data',
205                                                 xtype : 'SimpleStore',
206                                                 data : [ 
207                                                     [ 'P', "Purchased (eg. a standard product)"],
208                                                     [ 'R' , "Reference (Non-Product)"],
209                                                     [ 'K', "Kit (made up of products)"]  
210                                                 ],
211                                                 fields : [  'ftype', 'fname'],
212                                                 xns : Roo.data
213                                             },
214                                             '|xns' : 'Roo.form',
215                                             listWidth : 200,
216                                             triggerAction : 'all',
217                                             fieldLabel : 'Type',
218                                             displayField : 'fname',
219                                             emptyText : "Select Type",
220                                             hiddenName : 'item_type',
221                                             valueField : 'ftype',
222                                             xtype : 'ComboBox',
223                                             allowBlank : false,
224                                             showHide : function() {
225                                             
226                                                 var it = this.getValue();
227                                                 
228                                                 var options = [ 
229                                                     'item_itemcost_id_itemcost_curr_id',
230                                                     'item_itemcost_id_itemcost_actcost',
231                                                     'item_itemsite_id_itemsite_reorderlevel',
232                                                     'item_itemsite_id_itemsite_leadtime',
233                                                     'item_itemsite_id_itemsite_location_id',
234                                                     'item_itemsite_id_itemsite_loccntrl',
235                                                     'item_itemsite_id_itemsite_stocked',
236                                                     'item_itemsite_id_itemsite_perishable',
237                                                     
238                                                     'item_itemsite_id_itemsite_safetystock',
239                                                     'item_itemsite_id_itemsite_controlmethod',
240                                                     'item_itemsite_id_itemsite_plancode_id',
241                                                     'item_itemsite_id_itemsite_costcat_id',
242                                                     'item_itemsite_id_itemsite_active',
243                                                     'item_itemsite_id_itemsite_sold'
244                                                     
245                                                 ];
246                                                 
247                                                 var r_req = [ 
248                                                     'item_listprice'
249                                                 ];
250                                                 
251                                                 var state = true;
252                                                 
253                                                 _this.standardCostFieldSet.show();
254                                                 _this.itemsiteFieldSet.show();
255                                                 _this.form.findField('_update_related').setValue(1);
256                                                 
257                                                 switch(it) {
258                                                     case 'K':
259                                                         state = false;
260                                             
261                                                         _this.form.findField('item_listprice').allowBlank = false;
262                                                         _this.form.findField('item_listprice').actionMode = 'fieldEl';
263                                                         _this.form.findField('item_listprice').hideMode = 'display';
264                                                         _this.form.findField('item_listprice').show();
265                                                                     
266                                                         break;
267                                                         
268                                                     case 'R': // refrence
269                                                         options = options.concat(r_req);
270                                                         state = false;
271                                                         _this.standardCostFieldSet.hide();
272                                                         break;
273                                                         
274                                                     case 'P': // purchased..
275                                                         options = options.concat(r_req);
276                                                         // must have
277                                                         break;
278                                                 }
279                                                 
280                                                 Roo.each(options, function(n) {
281                                                     var ff = _this.form.findField(n);
282                                                     ff.allowBlank = !state;
283                                                     ff.actionMode = 'fieldEl';
284                                                     ff.hideMode = 'display';
285                                                     state ? ff.show() : ff.hide(); 
286                                                     
287                                                 });
288                                                 
289                                                 
290                                                 if(!state){
291                                                     _this.standardCostFieldSet.hide();
292                                                     _this.itemsiteFieldSet.hide();
293                                                     _this.form.findField('_update_related').setValue(0);
294                                                 }
295                                                 
296                                               
297                                                        
298                                             },
299                                             editable : false,
300                                             width : 200,
301                                             xns : Roo.form,
302                                             mode : 'local',
303                                             name : 'item_type_name',
304                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{fname}</b> </div>',
305                                             listeners : {
306                                                 beforeselect : function (combo, record, index)
307                                                    {
308                                                        (function() { combo.showHide(); }).defer(100);
309                                                    }
310                                             },
311                                             items : [
312
313                                             ]
314
315                                         },
316                                         {
317                                             store : {
318                                                 proxy : {
319                                                     '|xns' : 'Roo.data',
320                                                     url : baseURL + '/Roo/classcode.php',
321                                                     xtype : 'HttpProxy',
322                                                     method : 'GET',
323                                                     xns : Roo.data
324                                                 },
325                                                 reader : {
326                                                     '|xns' : 'Roo.data',
327                                                     id : 'id',
328                                                     root : 'data',
329                                                     xtype : 'JsonReader',
330                                                     xns : Roo.data,
331                                                     fields : [{"name":"id","type":"int"},{"name":"classcode_code","type":"string"}],
332                                                     totalProperty : 'total'
333                                                 },
334                                                 '|xns' : 'Roo.data',
335                                                 xtype : 'Store',
336                                                 remoteSort : true,
337                                                 sortInfo : { direction : 'ASC', field: 'id' },
338                                                 xns : Roo.data,
339                                                 listeners : {
340                                                         beforeload : function (_self, o){
341                                                                o.params = o.params || {};
342                                                                // set more here
343                                                            }
344                                                 },
345                                                 items : [
346
347                                                 ]
348
349                                             },
350                                             '|xns' : 'Roo.form',
351                                             listWidth : 400,
352                                             triggerAction : 'all',
353                                             fieldLabel : 'Class',
354                                             forceSelection : true,
355                                             selectOnFocus : true,
356                                             pageSize : 20,
357                                             displayField : 'classcode_code',
358                                             emptyText : "Select classcode",
359                                             hiddenName : 'item_classcode_id',
360                                             minChars : 2,
361                                             valueField : 'classcode_id',
362                                             xtype : 'ComboBox',
363                                             allowBlank : false,
364                                             typeAhead : true,
365                                             editable : false,
366                                             width : 200,
367                                             xns : Roo.form,
368                                             name : 'item_classcode_id_classcode_code',
369                                             qtip : "Select classcode",
370                                             queryParam : '',
371                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{classcode_code}</b> </div>',
372                                             loadingText : "Searching...",
373                                             items : [
374
375                                             ]
376
377                                         },
378                                         {
379                                             '|xns' : 'Roo.form',
380                                             fieldLabel : 'Weight',
381                                             xtype : 'NumberField',
382                                             allowBlank : false,
383                                             allowDecimals : true,
384                                             decimalPrecision : 2,
385                                             width : 200,
386                                             xns : Roo.form,
387                                             name : 'item_prodweight'
388                                         },
389                                         {
390                                             '|xns' : 'Roo.form',
391                                             fieldLabel : 'Item comments',
392                                             xtype : 'TextArea',
393                                             width : 200,
394                                             xns : Roo.form,
395                                             name : 'item_comments',
396                                             height : 100
397                                         },
398                                         {
399                                             '|xns' : 'Roo.form',
400                                             fieldLabel : 'Item sold',
401                                             inputValue : true,
402                                             xtype : 'Checkbox',
403                                             valueOff : 0,
404                                             width : 75,
405                                             xns : Roo.form,
406                                             name : 'item_sold'
407                                         },
408                                         {
409                                             '|xns' : 'Roo.form',
410                                             fieldLabel : 'Item active',
411                                             inputValue : true,
412                                             xtype : 'Checkbox',
413                                             valueOff : 0,
414                                             width : 75,
415                                             xns : Roo.form,
416                                             name : 'item_active'
417                                         },
418                                         {
419                                             store : {
420                                                 proxy : {
421                                                     '|xns' : 'Roo.data',
422                                                     url : baseURL + '/Roo/prodcat.php',
423                                                     xtype : 'HttpProxy',
424                                                     method : 'GET',
425                                                     xns : Roo.data
426                                                 },
427                                                 reader : {
428                                                     '|xns' : 'Roo.data',
429                                                     id : 'id',
430                                                     root : 'data',
431                                                     xtype : 'JsonReader',
432                                                     xns : Roo.data,
433                                                     fields : [{"name":"id","type":"int"},{"name":"prodcat_code","type":"string"}],
434                                                     totalProperty : 'total'
435                                                 },
436                                                 '|xns' : 'Roo.data',
437                                                 xtype : 'Store',
438                                                 remoteSort : true,
439                                                 xns : Roo.data,
440                                                 sortInfo : { direction : 'ASC', field: 'id' },
441                                                 listeners : {
442                                                         beforeload : function (_self, o){
443                                                                o.params = o.params || {};
444                                                                // set more here
445                                                            }
446                                                 },
447                                                 items : [
448
449                                                 ]
450
451                                             },
452                                             '|xns' : 'Roo.form',
453                                             alwaysQuery : true,
454                                             listWidth : 400,
455                                             triggerAction : 'all',
456                                             fieldLabel : 'Product Category',
457                                             forceSelection : true,
458                                             selectOnFocus : true,
459                                             pageSize : 20,
460                                             displayField : 'prodcat_code',
461                                             emptyText : "Select Category",
462                                             hiddenName : 'item_prodcat_id',
463                                             minChars : 2,
464                                             valueField : 'prodcat_id',
465                                             xtype : 'ComboBox',
466                                             allowBlank : false,
467                                             typeAhead : true,
468                                             editable : false,
469                                             width : 200,
470                                             xns : Roo.form,
471                                             name : 'item_prodcat_id_prodcat_code',
472                                             qtip : "Select prodcat",
473                                             queryParam : '',
474                                             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{prodcat_code}</b> </div>',
475                                             loadingText : "Searching...",
476                                             listeners : {
477                                                 add : function (combo)
478                                                    {
479                                                        Pman.Dialog.XtupleProdcat.show({prodcat_id : 0});
480                                                    },
481                                                 edit : function (combo, record)
482                                                    {
483                                                        var s = _this.form.findField('item_prodcat_id').getValue() * 1;
484                                                        if(s < 1){
485                                                            Roo.MessageBox.alert('Error','Please select a account assignment');
486                                                            return;
487                                                        }
488                                                        Pman.Dialog.XtupleProdcat.show({prodcat_id : s});
489                                                    }
490                                             },
491                                             items : [
492
493                                             ]
494
495                                         },
496                                         {
497                                             '|xns' : 'Roo.form',
498                                             fieldLabel : 'Sales Account',
499                                             xtype : 'DisplayField',
500                                             xns : Roo.form,
501                                             name : 'item_salesaccnt'
502                                         },
503                                         {
504                                             '|xns' : 'Roo.form',
505                                             fieldLabel : 'Item listprice',
506                                             xtype : 'NumberField',
507                                             width : 200,
508                                             xns : Roo.form,
509                                             name : 'item_listprice'
510                                         },
511                                         {
512                                             '|xns' : 'Roo.form',
513                                             style : 'width:320px',
514                                             xtype : 'FieldSet',
515                                             legend : "Standard Cost",
516                                             xns : Roo.form,
517                                             listeners : {
518                                                 render : function (_self)
519                                                    {
520                                                        _this.standardCostFieldSet = _self;
521                                                    }
522                                             },
523                                             items : [
524                                                 {
525                                                     store : {
526                                                         proxy : {
527                                                             '|xns' : 'Roo.data',
528                                                             url : baseURL + '/Roo/curr_symbol.php',
529                                                             xtype : 'HttpProxy',
530                                                             method : 'GET',
531                                                             xns : Roo.data
532                                                         },
533                                                         reader : {
534                                                             '|xns' : 'Roo.data',
535                                                             id : 'curr_id',
536                                                             root : 'data',
537                                                             xtype : 'JsonReader',
538                                                             xns : Roo.data,
539                                                             fields : [{"name":"curr_id","type":"int"},"curr_symbol"],
540                                                             totalProperty : 'total'
541                                                         },
542                                                         '|xns' : 'Roo.data',
543                                                         xtype : 'Store',
544                                                         remoteSort : true,
545                                                         sortInfo : { direction : 'ASC', field: 'curr_symbol' },
546                                                         xns : Roo.data,
547                                                         listeners : {
548                                                                 beforeload : function (_self, o){
549                                                                        o.params = o.params || {};
550                                                                        // set more here
551                                                                       
552                                                                    }
553                                                         },
554                                                         items : [
555
556                                                         ]
557
558                                                     },
559                                                     '|xns' : 'Roo.form',
560                                                     listWidth : 400,
561                                                     triggerAction : 'all',
562                                                     fieldLabel : 'Currency',
563                                                     forceSelection : true,
564                                                     selectOnFocus : true,
565                                                     pageSize : 20,
566                                                     displayField : 'curr_name',
567                                                     emptyText : "Select Currency",
568                                                     hiddenName : 'item_itemcost_id_itemcost_curr_id',
569                                                     minChars : 2,
570                                                     valueField : 'curr_id',
571                                                     xtype : 'ComboBox',
572                                                     allowBlank : false,
573                                                     typeAhead : true,
574                                                     editable : false,
575                                                     width : 200,
576                                                     xns : Roo.form,
577                                                     name : 'curr_name',
578                                                     qtip : "Select Currency",
579                                                     queryParam : 'query[curr_name]',
580                                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{curr_name}</b> </div>',
581                                                     loadingText : "Searching...",
582                                                     items : [
583
584                                                     ]
585
586                                                 },
587                                                 {
588                                                     '|xns' : 'Roo.form',
589                                                     fieldLabel : 'Value',
590                                                     xtype : 'NumberField',
591                                                     allowBlank : false,
592                                                     width : 200,
593                                                     xns : Roo.form,
594                                                     name : 'item_itemcost_id_itemcost_actcost'
595                                                 }
596                                             ]
597
598                                         }
599                                     ]
600
601                                 },
602                                 {
603                                     '|xns' : 'Roo.form',
604                                     xtype : 'Column',
605                                     xns : Roo.form,
606                                     items : [
607                                         {
608                                             '|xns' : 'Roo.form',
609                                             xtype : 'FieldSet',
610                                             legend : "Itemsite Settings",
611                                             xns : Roo.form,
612                                             style : 'width:335px;',
613                                             labelWidth : 120,
614                                             listeners : {
615                                                 render : function (_self)
616                                                    {
617                                                        _this.itemsiteFieldSet = _self;
618                                                    }
619                                             },
620                                             items : [
621                                                 {
622                                                     '|xns' : 'Roo.form',
623                                                     fieldLabel : 'Reorder Level',
624                                                     xtype : 'NumberField',
625                                                     allowBlank : false,
626                                                     width : 200,
627                                                     xns : Roo.form,
628                                                     name : 'item_itemsite_id_itemsite_reorderlevel'
629                                                 },
630                                                 {
631                                                     '|xns' : 'Roo.form',
632                                                     fieldLabel : 'Stock Safety Level',
633                                                     xtype : 'NumberField',
634                                                     allowBlank : false,
635                                                     width : 200,
636                                                     xns : Roo.form,
637                                                     name : 'item_itemsite_id_itemsite_safetystock'
638                                                 },
639                                                 {
640                                                     '|xns' : 'Roo.form',
641                                                     fieldLabel : 'Lead time (Days)',
642                                                     xtype : 'NumberField',
643                                                     allowBlank : false,
644                                                     width : 200,
645                                                     xns : Roo.form,
646                                                     name : 'item_itemsite_id_itemsite_leadtime'
647                                                 },
648                                                 {
649                                                     store : {
650                                                         '|xns' : 'Roo.data',
651                                                         xtype : 'SimpleStore',
652                                                         data : [ 
653                                                             [ 'N', "None"],
654                                                             [ 'R' , "Regular"]
655                                                         ],
656                                                         fields : [  'ftype', 'fname'],
657                                                         xns : Roo.data
658                                                     },
659                                                     '|xns' : 'Roo.form',
660                                                     listWidth : 200,
661                                                     triggerAction : 'all',
662                                                     fieldLabel : 'Control Method',
663                                                     displayField : 'fname',
664                                                     hiddenName : 'item_itemsite_id_itemsite_controlmethod',
665                                                     valueField : 'ftype',
666                                                     xtype : 'ComboBox',
667                                                     allowBlank : false,
668                                                     editable : false,
669                                                     width : 200,
670                                                     xns : Roo.form,
671                                                     mode : 'local',
672                                                     name : 'item_itemsite_id_itemsite_controlmethod_name',
673                                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{fname}</b> </div>',
674                                                     items : [
675
676                                                     ]
677
678                                                 },
679                                                 {
680                                                     store : {
681                                                         proxy : {
682                                                             '|xns' : 'Roo.data',
683                                                             url : baseURL + '/Roo/plancode.php',
684                                                             xtype : 'HttpProxy',
685                                                             method : 'GET',
686                                                             xns : Roo.data
687                                                         },
688                                                         reader : {
689                                                             '|xns' : 'Roo.data',
690                                                             id : 'id',
691                                                             root : 'data',
692                                                             xtype : 'JsonReader',
693                                                             xns : Roo.data,
694                                                             fields : [{"name":"id","type":"int"},{"name":"plancode_code","type":"string"}],
695                                                             totalProperty : 'total'
696                                                         },
697                                                         '|xns' : 'Roo.data',
698                                                         xtype : 'Store',
699                                                         remoteSort : true,
700                                                         xns : Roo.data,
701                                                         sortInfo : { direction : 'ASC', field: 'id' },
702                                                         listeners : {
703                                                                 beforeload : function (_self, o){
704                                                                        o.params = o.params || {};
705                                                                        // set more here
706                                                                    }
707                                                         },
708                                                         items : [
709
710                                                         ]
711
712                                                     },
713                                                     '|xns' : 'Roo.form',
714                                                     listWidth : 400,
715                                                     triggerAction : 'all',
716                                                     fieldLabel : 'Planner Code',
717                                                     forceSelection : true,
718                                                     selectOnFocus : true,
719                                                     pageSize : 20,
720                                                     displayField : 'plancode_name',
721                                                     emptyText : "Select plancode",
722                                                     hiddenName : 'item_itemsite_id_itemsite_plancode_id',
723                                                     minChars : 2,
724                                                     valueField : 'plancode_id',
725                                                     xtype : 'ComboBox',
726                                                     allowBlank : false,
727                                                     typeAhead : true,
728                                                     editable : false,
729                                                     width : 200,
730                                                     xns : Roo.form,
731                                                     name : 'plancode_name',
732                                                     qtip : "Select plancode",
733                                                     queryParam : '',
734                                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{plancode_name}</b> </div>',
735                                                     loadingText : "Searching...",
736                                                     items : [
737
738                                                     ]
739
740                                                 },
741                                                 {
742                                                     store : {
743                                                         proxy : {
744                                                             '|xns' : 'Roo.data',
745                                                             url : baseURL + '/Roo/costcat.php',
746                                                             xtype : 'HttpProxy',
747                                                             method : 'GET',
748                                                             xns : Roo.data
749                                                         },
750                                                         reader : {
751                                                             '|xns' : 'Roo.data',
752                                                             id : 'id',
753                                                             root : 'data',
754                                                             xtype : 'JsonReader',
755                                                             xns : Roo.data,
756                                                             fields : [{"name":"id","type":"int"},{"name":"costcat_code","type":"string"}],
757                                                             totalProperty : 'total'
758                                                         },
759                                                         '|xns' : 'Roo.data',
760                                                         xtype : 'Store',
761                                                         remoteSort : true,
762                                                         xns : Roo.data,
763                                                         sortInfo : { direction : 'ASC', field: 'id' },
764                                                         listeners : {
765                                                                 beforeload : function (_self, o){
766                                                                        o.params = o.params || {};
767                                                                        // set more here
768                                                                    }
769                                                         },
770                                                         items : [
771
772                                                         ]
773
774                                                     },
775                                                     '|xns' : 'Roo.form',
776                                                     listWidth : 400,
777                                                     triggerAction : 'all',
778                                                     fieldLabel : 'Costcat',
779                                                     forceSelection : true,
780                                                     selectOnFocus : true,
781                                                     pageSize : 20,
782                                                     displayField : 'costcat_code',
783                                                     emptyText : "Select costcat",
784                                                     hiddenName : 'item_itemsite_id_itemsite_costcat_id',
785                                                     minChars : 2,
786                                                     valueField : 'costcat_id',
787                                                     xtype : 'ComboBox',
788                                                     allowBlank : false,
789                                                     typeAhead : true,
790                                                     editable : false,
791                                                     width : 200,
792                                                     xns : Roo.form,
793                                                     name : 'costcat_code',
794                                                     qtip : "Select costcat",
795                                                     queryParam : '',
796                                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{costcat_code}</b> </div>',
797                                                     loadingText : "Searching...",
798                                                     items : [
799
800                                                     ]
801
802                                                 },
803                                                 {
804                                                     '|xns' : 'Roo.form',
805                                                     fieldLabel : 'Active',
806                                                     inputValue : true,
807                                                     xtype : 'Checkbox',
808                                                     valueOff : 0,
809                                                     width : 75,
810                                                     xns : Roo.form,
811                                                     name : 'item_itemsite_id_itemsite_active'
812                                                 },
813                                                 {
814                                                     '|xns' : 'Roo.form',
815                                                     fieldLabel : 'Sold',
816                                                     inputValue : true,
817                                                     xtype : 'Checkbox',
818                                                     valueOff : 0,
819                                                     width : 75,
820                                                     xns : Roo.form,
821                                                     name : 'item_itemsite_id_itemsite_sold'
822                                                 },
823                                                 {
824                                                     '|xns' : 'Roo.form',
825                                                     fieldLabel : 'Stocked',
826                                                     inputValue : true,
827                                                     xtype : 'Checkbox',
828                                                     valueOff : 0,
829                                                     width : 75,
830                                                     xns : Roo.form,
831                                                     name : 'item_itemsite_id_itemsite_stocked'
832                                                 },
833                                                 {
834                                                     '|xns' : 'Roo.form',
835                                                     fieldLabel : 'Perishable',
836                                                     inputValue : true,
837                                                     xtype : 'Checkbox',
838                                                     valueOff : 0,
839                                                     width : 75,
840                                                     xns : Roo.form,
841                                                     name : 'item_itemsite_id_itemsite_perishable'
842                                                 },
843                                                 {
844                                                     '|xns' : 'Roo.form',
845                                                     fieldLabel : 'Multi Location',
846                                                     inputValue : true,
847                                                     xtype : 'Checkbox',
848                                                     valueOff : 0,
849                                                     width : 100,
850                                                     xns : Roo.form,
851                                                     name : 'item_itemsite_id_itemsite_loccntrl'
852                                                 },
853                                                 {
854                                                     store : {
855                                                         proxy : {
856                                                             '|xns' : 'Roo.data',
857                                                             url : baseURL + '/Roo/location.php',
858                                                             method : 'GET',
859                                                             xtype : 'HttpProxy',
860                                                             xns : Roo.data
861                                                         },
862                                                         reader : {
863                                                             '|xns' : 'Roo.data',
864                                                             id : 'location_id',
865                                                             root : 'data',
866                                                             xtype : 'JsonReader',
867                                                             fields : [{"name":"location_id","type":"int"},"location_name"],
868                                                             xns : Roo.data,
869                                                             totalProperty : 'total'
870                                                         },
871                                                         '|xns' : 'Roo.data',
872                                                         xtype : 'Store',
873                                                         remoteSort : true,
874                                                         sortInfo : { direction : 'ASC', field: 'location_name' },
875                                                         xns : Roo.data,
876                                                         listeners : {
877                                                                 beforeload : function (_self, o){
878                                                                        o.params = o.params || {};
879                                                                        // set more here
880                                                                         o.params.location_netable = 1;
881                                                                         o.params._notinternalcompany = 1;
882                                                                         o.params.location_restrict = 0;
883                                                                    }
884                                                         },
885                                                         items : [
886
887                                                         ]
888
889                                                     },
890                                                     '|xns' : 'Roo.form',
891                                                     listWidth : 400,
892                                                     triggerAction : 'all',
893                                                     fieldLabel : 'Default Location',
894                                                     forceSelection : true,
895                                                     selectOnFocus : true,
896                                                     pageSize : 200,
897                                                     displayField : 'location_name',
898                                                     emptyText : "Default Location",
899                                                     hiddenName : 'item_itemsite_id_itemsite_location_id',
900                                                     minChars : 2,
901                                                     valueField : 'location_id',
902                                                     xtype : 'ComboBox',
903                                                     allowBlank : false,
904                                                     typeAhead : false,
905                                                     editable : true,
906                                                     width : 200,
907                                                     xns : Roo.form,
908                                                     name : 'location_name',
909                                                     qtip : "Select terms",
910                                                     queryParam : 'query[location_name]',
911                                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{location_name}</b> </div>',
912                                                     loadingText : "Searching...",
913                                                     items : [
914
915                                                     ]
916
917                                                 }
918                                             ]
919
920                                         }
921                                     ]
922
923                                 },
924                                 {
925                                     '|xns' : 'Roo.form',
926                                     xtype : 'Hidden',
927                                     xns : Roo.form,
928                                     width : 75,
929                                     name : 'item_id'
930                                 },
931                                 {
932                                     '|xns' : 'Roo.form',
933                                     value : 1,
934                                     xtype : 'Hidden',
935                                     width : 75,
936                                     xns : Roo.form,
937                                     name : '_update_related'
938                                 }
939                             ]
940
941                         }
942                     ]
943
944                 },
945                 {
946                     grid : {
947                         toolbar : {
948                             '|xns' : 'Roo',
949                             xtype : 'Toolbar',
950                             xns : Roo,
951                             items : [
952                                 {
953                                     store : {
954                                         proxy : {
955                                             '|xns' : 'Roo.data',
956                                             url : baseURL + '/Roo/Core_enum.php',
957                                             method : 'GET',
958                                             xtype : 'HttpProxy',
959                                             xns : Roo.data
960                                         },
961                                         reader : {
962                                             '|xns' : 'Roo.data',
963                                             id : 'id',
964                                             root : 'data',
965                                             xtype : 'JsonReader',
966                                             fields : [
967                                                 {"name":"id","type":"int"},
968                                                 {"name":"name","type":"string"},
969                                                 {"name":"display_name","type":"string"}
970                                             ],
971                                             xns : Roo.data,
972                                             totalProperty : 'total'
973                                         },
974                                         '|xns' : 'Roo.data',
975                                         xtype : 'Store',
976                                         remoteSort : true,
977                                         sortInfo : { direction : 'ASC', field: 'name' },
978                                         xns : Roo.data,
979                                         listeners : {
980                                                 beforeload : function (_self, o){
981                                                        o.params = o.params || {};
982                                                        
983                                                        o.params.etype = 'crm_interest';
984                                                        o.params.active = 1;
985                                                    }
986                                         },
987                                         items : [
988
989                                         ]
990
991                                     },
992                                     '|xns' : 'Roo.bootstrap',
993                                     alwaysQuery : true,
994                                     listWidth : 400,
995                                     triggerAction : 'all',
996                                     fieldLabel : 'Interests',
997                                     forceSelection : true,
998                                     selectOnFocus : true,
999                                     pageSize : 20,
1000                                     displayField : 'display_name',
1001                                     emptyText : "Select interests",
1002                                     hiddenName : 'id',
1003                                     minChars : 2,
1004                                     valueField : 'id',
1005                                     xtype : 'ComboBox',
1006                                     allowBlank : true,
1007                                     typeAhead : true,
1008                                     editable : true,
1009                                     width : 200,
1010                                     xns : Roo.bootstrap,
1011                                     name : 'name',
1012                                     qtip : "Select Interests",
1013                                     queryParam : 'query[search]',
1014                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1015                                     loadingText : "Searching...",
1016                                     listeners : {
1017                                         render : function (_self)
1018                                            {
1019                                                _this.partsBox = _self;
1020                                            },
1021                                         select : function (combo, record, index)
1022                                            {
1023                                                Roo.log('record');
1024                                                Roo.log(record);
1025                                               /* var event_id = _this.form.findField('id').getValue() * 1;
1026                                                
1027                                                if(typeof(record) == 'undefined' || !record || record.data.id * 1 < 1 || event_id < 1){
1028                                                    return;
1029                                                }
1030                                                
1031                                                var err = false;
1032                                            
1033                                                _this.fgrid.ds.each(function(d){
1034                                                    if(record.data.id == d.data.interest_id){
1035                                                        err = true;
1036                                                    }
1037                                                });
1038                                            
1039                                                if(err){
1040                                                    Roo.MessageBox.alert('Error', record.data.display_name + ' already exists!');
1041                                                    _this.focusBox.reset();
1042                                                    return;
1043                                                }
1044                                                
1045                                                new Pman.Request({
1046                                                    url : baseURL + '/Roo/cal_event_focus.php',
1047                                                    method : 'POST',
1048                                                    params : {
1049                                                        cal_event_id : event_id,
1050                                                        interest_id : record.data.id
1051                                                    }, 
1052                                                    success : function(res) {
1053                                                        _this.focusBox.reset();
1054                                                        _this.fgrid.footer.onClick('first');
1055                                                    }
1056                                                }); */
1057                                            }
1058                                     },
1059                                     items : [
1060
1061                                     ]
1062
1063                                 },
1064                                 {
1065                                     '|xns' : 'Roo.Toolbar',
1066                                     xtype : 'Separator',
1067                                     xns : Roo.Toolbar
1068                                 },
1069                                 {
1070                                     '|xns' : 'Roo',
1071                                     text : "Add",
1072                                     xtype : 'Button',
1073                                     cls : 'x-btn-text-icon',
1074                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1075                                     xns : Roo,
1076                                     listeners : {
1077                                         click : function()
1078                                            {
1079                                               Pman.Dialog.CoreEnum.show( {id : 0, etype : 'crm_interest'}, function(res){
1080                                                    _this.focusBox.setFromData(res);
1081                                                    var record = {};
1082                                                    
1083                                                    record.data = res;
1084                                                    
1085                                                    _this.focusBox.fireEvent('select', _this.focusBox, record);
1086                                                    
1087                                               }); 
1088                                            }
1089                                     }
1090                                 },
1091                                 {
1092                                     '|xns' : 'Roo.Toolbar',
1093                                     xtype : 'Fill',
1094                                     xns : Roo.Toolbar
1095                                 },
1096                                 {
1097                                     '|xns' : 'Roo',
1098                                     text : "Remove",
1099                                     xtype : 'Button',
1100                                     cls : 'x-btn-text-icon',
1101                                     icon : rootURL + '/Pman/templates/images/trash.gif',
1102                                     xns : Roo,
1103                                     listeners : {
1104                                         click : function ()
1105                                            {
1106                                                var sel = _this.fgrid.getSelectionModel().getSelections();
1107                                                
1108                                                if(!sel || !sel.length){
1109                                                    Roo.MessageBox.alert("Error", "Please select interests from below list");
1110                                                    return;
1111                                                }
1112                                                
1113                                                Roo.log(sel);
1114                                                        
1115                                                var id = [];
1116                                                
1117                                                Roo.each(sel, function(s){
1118                                                    if(s.data.id * 1 < 1){ // bad data?
1119                                                        return;
1120                                                    }
1121                                                    
1122                                                    id.push(s.data.id);
1123                                                });
1124                                                
1125                                                new Pman.Request({
1126                                                    url : baseURL + '/Roo/cal_event_focus.php',
1127                                                    method : 'POST',
1128                                                    params : {
1129                                                        _delete : id.join(',')
1130                                                    }, 
1131                                                    success : function(res) {
1132                                                        _this.fgrid.footer.onClick('first');
1133                                                    }
1134                                                }); 
1135                                               
1136                                            }
1137                                     }
1138                                 }
1139                             ]
1140
1141                         },
1142                         dataSource : {
1143                             proxy : {
1144                                 '|xns' : 'Roo.data',
1145                                 url : baseURL + '/Roo/bomitem.php',
1146                                 xtype : 'HttpProxy',
1147                                 method : 'GET',
1148                                 xns : Roo.data
1149                             },
1150                             reader : {
1151                                 '|xns' : 'Roo.data',
1152                                 id : 'bom_id',
1153                                 root : 'data',
1154                                 xtype : 'JsonReader',
1155                                 fields : [
1156                                     {
1157                                         'name': 'bomitem_id',
1158                                         'type': 'int'
1159                                     }
1160                                 ],
1161                                 xns : Roo.data,
1162                                 totalProperty : 'total'
1163                             },
1164                             '|xns' : 'Roo.data',
1165                             xtype : 'Store',
1166                             remoteSort : true,
1167                             sortInfo : { field : 'bomitem_item_id_item_name', direction: 'ASC' },
1168                             xns : Roo.data,
1169                             listeners : {
1170                                 beforeload : function (_self, o)
1171                                    {
1172                                       o.params = o.params || {};
1173                                       
1174                                       var id  = _this.form.findField('item_id').getValue() * 1;
1175                                       if(id < 1){
1176                                            return false;
1177                                       }
1178                                       
1179                                       o.params.bom_parent_item_id = id;
1180                                    }
1181                             },
1182                             items : [
1183
1184                             ]
1185
1186                         },
1187                         footer : {
1188                             '|xns' : 'Roo',
1189                             pageSize : 50,
1190                             xtype : 'PagingToolbar',
1191                             emptyMsg : "Nothing found",
1192                             xns : Roo,
1193                             displayMsg : "Displaying parts {0} - {1} of {2}",
1194                             displayInfo : true
1195                         },
1196                         '|xns' : 'Roo.grid',
1197                         autoExpandColumn : 'bomitem_item_id_item_descrip1',
1198                         xtype : 'EditorGrid',
1199                         loadMask : true,
1200                         clicksToEdit : 1,
1201                         xns : Roo.grid,
1202                         colModel : [
1203                                  {
1204                                         '|xns' : 'Roo.grid',
1205                                         xtype : 'ColumnModel',
1206                                         header : 'Name',
1207                                         width : 150,
1208                                         renderer : function(v) { return String.format('{0}', v); },
1209                                         xns : Roo.grid,
1210                                         dataIndex : 'bomitem_item_id_item_name'
1211                                     },
1212 {
1213                                         '|xns' : 'Roo.grid',
1214                                         xtype : 'ColumnModel',
1215                                         header : 'Description',
1216                                         width : 150,
1217                                         renderer : function(v) { return String.format('{0}', v); },
1218                                         xns : Roo.grid,
1219                                         dataIndex : 'bomitem_item_id_item_descrip1'
1220                                     },
1221 {
1222                                         '|xns' : 'Roo.grid',
1223                                         xtype : 'ColumnModel',
1224                                         header : 'Qty',
1225                                         width : 100,
1226                                         renderer : function(v) { return String.format('{0}', v); },
1227                                         xns : Roo.grid,
1228                                         dataIndex : 'bomitem_qtyper'
1229                                     }
1230                         ],
1231                         listeners : {
1232                                 beforeedit : function (e)
1233                                    {
1234                                        if(e.field != 'ipshead_ipsitem_price'){
1235                                            return false;
1236                                        }
1237                                        
1238                                    },
1239                                 render : function() 
1240                                    {
1241                                        _this.partsgrid = this; 
1242                                        //_this.dialog = Pman.Dialog.FILL_IN
1243                                        if (_this.partspanel.active) {
1244                                           this.footer.onClick('first');
1245                                        }
1246                                    },
1247                                 afteredit : function (e)
1248                                    {
1249                                        if(e.originalValue == e.value){
1250                                            return false;
1251                                        }
1252                                        return false;
1253                                        
1254                                        
1255                                        var id = _this.form.findField('item_id').getValue() * 1;
1256                                        if(id < 1){
1257                                            return false;
1258                                        }
1259                                        
1260                                        new Pman.Request({
1261                                            method : 'POST',
1262                                            url : baseURL + '/Roo/ipsiteminfo',
1263                                            mask : 'Saving',
1264                                            params : {
1265                                                ipsitem_ipshead_id : e.record.data.ipshead_id,
1266                                                ipsitem_item_id : id,
1267                                                ipsitem_price : e.record.data.ipshead_ipsitem_price,
1268                                                ipsitem_id : e.record.data.ipshead_ipsitem_id
1269                                            }
1270                                        
1271                                        });
1272                                            
1273                                             
1274                                            
1275                                            
1276                                    }
1277                         },
1278                         items : [
1279
1280                         ]
1281
1282                     },
1283                     '|xns' : 'Roo',
1284                     background : true,
1285                     region : 'center',
1286                     fitToframe : true,
1287                     title : "Item Parts",
1288                     xtype : 'GridPanel',
1289                     fitContainer : true,
1290                     xns : Roo,
1291                     tableName : 'bomitem',
1292                     listeners : {
1293                         activate : function() {
1294                                _this.lpanel = this;
1295                                
1296                                try { if (MODULE.isBuilder) {
1297                                    return;
1298                                } } catch(e) { }
1299                                
1300                                var id = _this.form.findField('item_id').getValue() * 1;
1301                                if (id < 1) {
1302                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding parts");
1303                                    _this.dialog.layout.getRegion('center').showPanel(0);
1304                                    return;
1305                                }
1306                                
1307                                var type = _this.form.findField('item_type').getValue();
1308                                
1309                                if(!type.length || type != 'K'){
1310                                    Roo.MessageBox.alert("Error", "Can't add parts to non-kit item");
1311                                    _this.dialog.layout.getRegion('center').showPanel(0);
1312                                    return;
1313                                }
1314                                
1315                                if (_this.partsgrid) {
1316                                    _this.partsgrid.footer.onClick('first');
1317                                
1318                                 }
1319                            }
1320                     },
1321                     items : [
1322
1323                     ]
1324
1325                 },
1326                 {
1327                     grid : {
1328                         dataSource : {
1329                             reader : {
1330                                 '|xns' : 'Roo.data',
1331                                 id : 'id',
1332                                 root : 'data',
1333                                 xtype : 'JsonReader',
1334                                 fields : [
1335                                     {
1336                                         'name': 'id',
1337                                         'type': 'int'
1338                                     },
1339                                     {
1340                                         'name': 'filename',
1341                                         'type': 'string'
1342                                     },
1343                                     {
1344                                         'name': 'ontable',
1345                                         'type': 'string'
1346                                     },
1347                                     {
1348                                         'name': 'onid',
1349                                         'type': 'int'
1350                                     },
1351                                     {
1352                                         'name': 'mimetype',
1353                                         'type': 'string'
1354                                     },
1355                                     {
1356                                         'name': 'width',
1357                                         'type': 'int'
1358                                     },
1359                                     {
1360                                         'name': 'height',
1361                                         'type': 'int'
1362                                     },
1363                                     {
1364                                         'name': 'filesize',
1365                                         'type': 'int'
1366                                     },
1367                                     {
1368                                         'name': 'displayorder',
1369                                         'type': 'int'
1370                                     },
1371                                     {
1372                                         'name': 'language',
1373                                         'type': 'string'
1374                                     },
1375                                     {
1376                                         'name': 'parent_image_id',
1377                                         'type': 'int'
1378                                     },
1379                                     {
1380                                         'name': 'created',
1381                                         'type': 'date',
1382                                         'dateFormat' : 'Y-m-d H:i:s'
1383                                     },
1384                                     {
1385                                         'name': 'imgtype',
1386                                         'type': 'string'
1387                                     },
1388                                     {
1389                                         'name': 'linkurl',
1390                                         'type': 'string'
1391                                     },
1392                                     {
1393                                         'name': 'descript',
1394                                         'type': 'string'
1395                                     },
1396                                     {
1397                                         'name': 'title',
1398                                         'type': 'string'
1399                                     }
1400                                 ],
1401                                 xns : Roo.data,
1402                                 totalProperty : 'total'
1403                             },
1404                             proxy : {
1405                                 '|xns' : 'Roo.data',
1406                                 url : baseURL + '/Roo/Images.php',
1407                                 xtype : 'HttpProxy',
1408                                 method : 'GET',
1409                                 xns : Roo.data
1410                             },
1411                             '|xns' : 'Roo.data',
1412                             xtype : 'Store',
1413                             remoteSort : true,
1414                             sortInfo : { field: 'created' , direction: 'DESC' },
1415                             xns : Roo.data,
1416                             listeners : {
1417                                 beforeload : function (_self, o)
1418                                    {
1419                                        o.params = o.params || {};
1420                                        
1421                                        var id = _this.form.findField('item_id').getValue();
1422                                        
1423                                        if(id * 1 < 1){
1424                                            return false;
1425                                        }
1426                                        
1427                                        o.params.onid = id;
1428                                        o.params.ontable = 'item';
1429                                        
1430                                    }
1431                             },
1432                             items : [
1433
1434                             ]
1435
1436                         },
1437                         footer : {
1438                             '|xns' : 'Roo',
1439                             pageSize : 25,
1440                             xtype : 'PagingToolbar',
1441                             emptyMsg : "No Images found",
1442                             xns : Roo,
1443                             displayInfo : true,
1444                             displayMsg : "Displaying Images  {0} - {1} of {2}"
1445                         },
1446                         toolbar : {
1447                             '|xns' : 'Roo',
1448                             xtype : 'Toolbar',
1449                             xns : Roo,
1450                             items : [
1451                                 {
1452                                     '|xns' : 'Roo.Toolbar',
1453                                     text : "Add",
1454                                     xtype : 'Button',
1455                                     cls : 'x-btn-text-icon',
1456                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1457                                     xns : Roo.Toolbar,
1458                                     listeners : {
1459                                         click : function()
1460                                            {
1461                                                Pman.Dialog.Image.show({
1462                                                    id : 0, 
1463                                                    ontable: 'item',
1464                                                    onid: _this.form.findField('item_id').getValue() * 1,
1465                                                    imgtype : ''
1466                                                }, function(data){
1467                                                    if (!data) { return; } 
1468                                                    _this.grid.footer.onClick('first');
1469                                                }); 
1470                                            
1471                                            }
1472                                     }
1473                                 },
1474                                 {
1475                                     '|xns' : 'Roo.Toolbar',
1476                                     text : "Delete",
1477                                     xtype : 'Button',
1478                                     cls : 'x-btn-text-icon',
1479                                     icon : rootURL + '/Pman/templates/images/trash.gif',
1480                                     xns : Roo.Toolbar,
1481                                     listeners : {
1482                                         click : function()
1483                                            {
1484                                                Pman.genericDelete(_this, 'Images'); 
1485                                            }
1486                                     }
1487                                 }
1488                             ]
1489
1490                         },
1491                         '|xns' : 'Roo.grid',
1492                         autoExpandColumn : 'id',
1493                         xtype : 'Grid',
1494                         loadMask : true,
1495                         xns : Roo.grid,
1496                         colModel : [
1497                                  {
1498                                         '|xns' : 'Roo.grid',
1499                                         xtype : 'ColumnModel',
1500                                         sortable : true,
1501                                         header : 'Created',
1502                                         width : 200,
1503                                         renderer : function(v,x,r) {
1504                                                return String.format('{0}<br/><i>{1}</i><br/>{2}<br/><i>{3}x{4}</i>',
1505                                                     v.format('d/M/Y'), r.data.mimetype, r.data.filename,
1506                                             r.data.width, r.data.height
1507                                             ); 
1508                                         },
1509                                         xns : Roo.grid,
1510                                         dataIndex : 'created'
1511                                     },
1512 {
1513                                         '|xns' : 'Roo.grid',
1514                                         xtype : 'ColumnModel',
1515                                         width : 100,
1516                                         header : 'Image',
1517                                         renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.filename); },
1518                                         xns : Roo.grid,
1519                                         dataIndex : 'id'
1520                                     }
1521                         ],
1522                         listeners : {
1523                                 rowdblclick : function (_self, rowIndex, e)
1524                                    {
1525                                      
1526                                       var s =  _self.getDataSource().getAt(rowIndex);
1527                                       new Pman.Download({
1528                                            url : baseURL + '/Images/Download/' + s.data.id
1529                                        });
1530                                       
1531                                    },
1532                                 render : function() { 
1533                                        _this.grid = this; 
1534                                    
1535                                        if (_this.panel.active) {
1536                                           this.footer.onClick('first');
1537                                        }
1538                                    }
1539                         },
1540                         items : [
1541
1542                         ]
1543
1544                     },
1545                     '|xns' : 'Roo',
1546                     region : 'center',
1547                     fitToframe : true,
1548                     background : true,
1549                     title : "Reference Files",
1550                     xtype : 'GridPanel',
1551                     fitContainer : true,
1552                     xns : Roo,
1553                     tableName : 'Images',
1554                     listeners : {
1555                         activate : function() {
1556                                _this.panel = this;
1557                                
1558                                try { if (MODULE.isBuilder) {
1559                                    return;
1560                                } } catch(e) { }
1561                                
1562                                var id = _this.form.findField('item_id').getValue() * 1;
1563                                if (id < 1) {
1564                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding image");
1565                                    _this.dialog.layout.getRegion('center').showPanel(0);
1566                                    return;
1567                                }
1568                                
1569                                if (_this.grid) {
1570                                    _this.grid.footer.onClick('first');
1571                                
1572                                 }
1573                            }
1574                     },
1575                     items : [
1576
1577                     ]
1578
1579                 },
1580                 {
1581                     grid : {
1582                         dataSource : {
1583                             proxy : {
1584                                 '|xns' : 'Roo.data',
1585                                 url : baseURL + '/Roo/ipshead.php',
1586                                 method : 'GET',
1587                                 xtype : 'HttpProxy',
1588                                 xns : Roo.data
1589                             },
1590                             reader : {
1591                                 '|xns' : 'Roo.data',
1592                                 id : 'ipshead_id',
1593                                 root : 'data',
1594                                 xtype : 'JsonReader',
1595                                 fields : [
1596                                     {
1597                                         'name': 'ipshead_id',
1598                                         'type': 'int'
1599                                     },
1600                                     {
1601                                         'name': 'ipshead_name',
1602                                         'type': 'string'
1603                                     }
1604                                 ],
1605                                 xns : Roo.data,
1606                                 totalProperty : 'total'
1607                             },
1608                             '|xns' : 'Roo.data',
1609                             xtype : 'Store',
1610                             remoteSort : true,
1611                             sortInfo : { field : 'ipshead_id', direction: 'ASC' },
1612                             xns : Roo.data,
1613                             listeners : {
1614                                 beforeload : function (_self, o)
1615                                    {
1616                                       o.params = o.params || {};
1617                                       
1618                                       var id  = _this.form.findField('item_id').getValue() * 1;
1619                                       if(id < 1){
1620                                            return false;
1621                                       }
1622                                       
1623                                       o.params._with_item = id;
1624                                    }
1625                             },
1626                             items : [
1627
1628                             ]
1629
1630                         },
1631                         footer : {
1632                             '|xns' : 'Roo',
1633                             pageSize : 50,
1634                             xtype : 'PagingToolbar',
1635                             emptyMsg : "Nothing found",
1636                             xns : Roo,
1637                             displayMsg : "Displaying records {0} - {1} of {2}",
1638                             displayInfo : true
1639                         },
1640                         '|xns' : 'Roo.grid',
1641                         autoExpandColumn : 'ipshead_descrip',
1642                         xtype : 'EditorGrid',
1643                         loadMask : true,
1644                         clicksToEdit : 1,
1645                         xns : Roo.grid,
1646                         colModel : [
1647                                  {
1648                                         '|xns' : 'Roo.grid',
1649                                         xtype : 'ColumnModel',
1650                                         width : 150,
1651                                         header : 'Name',
1652                                         renderer : function(v) { return String.format('{0}', v); },
1653                                         xns : Roo.grid,
1654                                         dataIndex : 'ipshead_name'
1655                                     },
1656 {
1657                                         '|xns' : 'Roo.grid',
1658                                         xtype : 'ColumnModel',
1659                                         width : 150,
1660                                         header : 'Description',
1661                                         renderer : function(v) { return String.format('{0}', v); },
1662                                         xns : Roo.grid,
1663                                         dataIndex : 'ipshead_descrip'
1664                                     },
1665 {
1666                                         '|xns' : 'Roo.grid',
1667                                         xtype : 'ColumnModel',
1668                                         width : 100,
1669                                         header : 'Currency',
1670                                         renderer : function(v) { return String.format('{0}', v); },
1671                                         xns : Roo.grid,
1672                                         dataIndex : 'ipshead_curr_id_curr_name'
1673                                     },
1674 {
1675                                         editor : {
1676                                             field : {
1677                                                 '|xns' : 'Roo.form',
1678                                                 xtype : 'NumberField',
1679                                                 cls : 'align-right',
1680                                                 decimalPrecision : 2,
1681                                                 xns : Roo.form
1682                                             },
1683                                             '|xns' : 'Roo.grid',
1684                                             xtype : 'GridEditor',
1685                                             xns : Roo.grid,
1686                                             items : [
1687
1688                                             ]
1689
1690                                         },
1691                                         '|xns' : 'Roo.grid',
1692                                         align : 'right',
1693                                         xtype : 'ColumnModel',
1694                                         header : 'Price',
1695                                         width : 120,
1696                                         renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
1697                                         xns : Roo.grid,
1698                                         dataIndex : 'ipshead_ipsitem_price',
1699                                         items : [
1700
1701                                         ]
1702
1703                                     }
1704                         ],
1705                         listeners : {
1706                                 beforeedit : function (e)
1707                                    {
1708                                        if(e.field != 'ipshead_ipsitem_price'){
1709                                            return false;
1710                                        }
1711                                        
1712                                    },
1713                                 render : function() 
1714                                    {
1715                                        _this.lgrid = this; 
1716                                        //_this.dialog = Pman.Dialog.FILL_IN
1717                                        if (_this.lpanel.active) {
1718                                           this.footer.onClick('first');
1719                                        }
1720                                    },
1721                                 afteredit : function (e)
1722                                    {
1723                                        if(e.originalValue == e.value){
1724                                            return false;
1725                                        }
1726                                        
1727                                        var id = _this.form.findField('item_id').getValue() * 1;
1728                                        if(id < 1){
1729                                            return false;
1730                                        }
1731                                        
1732                                        new Pman.Request({
1733                                            method : 'POST',
1734                                            url : baseURL + '/Roo/ipsiteminfo',
1735                                            mask : 'Saving',
1736                                            params : {
1737                                                ipsitem_ipshead_id : e.record.data.ipshead_id,
1738                                                ipsitem_item_id : id,
1739                                                ipsitem_price : e.record.data.ipshead_ipsitem_price,
1740                                                ipsitem_id : e.record.data.ipshead_ipsitem_id
1741                                            }
1742                                        
1743                                        });
1744                                            
1745                                             
1746                                            
1747                                            
1748                                    }
1749                         },
1750                         items : [
1751
1752                         ]
1753
1754                     },
1755                     '|xns' : 'Roo',
1756                     region : 'center',
1757                     fitToframe : true,
1758                     background : true,
1759                     title : "Price List",
1760                     xtype : 'GridPanel',
1761                     fitContainer : true,
1762                     xns : Roo,
1763                     tableName : 'ipshead',
1764                     listeners : {
1765                         activate : function() {
1766                                _this.lpanel = this;
1767                                
1768                                try { if (MODULE.isBuilder) {
1769                                    return;
1770                                } } catch(e) { }
1771                                
1772                                var id = _this.form.findField('item_id').getValue() * 1;
1773                                if (id < 1) {
1774                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding image");
1775                                    _this.dialog.layout.getRegion('center').showPanel(0);
1776                                    return;
1777                                }
1778                                
1779                                if (_this.lgrid) {
1780                                    _this.lgrid.footer.onClick('first');
1781                                
1782                                 }
1783                            }
1784                     },
1785                     items : [
1786
1787                     ]
1788
1789                 },
1790                 {
1791                     grid : {
1792                         dataSource : {
1793                             proxy : {
1794                                 '|xns' : 'Roo.data',
1795                                 url : baseURL + '/Roo/itemsrc.php',
1796                                 xtype : 'HttpProxy',
1797                                 method : 'GET',
1798                                 xns : Roo.data
1799                             },
1800                             reader : {
1801                                 '|xns' : 'Roo.data',
1802                                 id : 'id',
1803                                 root : 'data',
1804                                 xtype : 'JsonReader',
1805                                 xns : Roo.data,
1806                                 fields : [
1807                                     {
1808                                         'name': 'itemsrc_id',
1809                                         'type': 'int'
1810                                     },
1811                                     {
1812                                         'name': 'itemsrc_item_id',
1813                                         'type': 'int'
1814                                     },
1815                                     {
1816                                         'name': 'itemsrc_item_id',
1817                                         'type': 'int'
1818                                     },
1819                                     {
1820                                         'name': 'itemsrc_vend_id',
1821                                         'type': 'int'
1822                                     },
1823                                     {
1824                                         'name': 'itemsrc_vend_id',
1825                                         'type': 'int'
1826                                     },
1827                                     {
1828                                         'name': 'itemsrc_vend_item_number',
1829                                         'type': 'string'
1830                                     },
1831                                     {
1832                                         'name': 'itemsrc_vend_item_descrip',
1833                                         'type': 'string'
1834                                     },
1835                                     {
1836                                         'name': 'itemsrc_comments',
1837                                         'type': 'string'
1838                                     },
1839                                     {
1840                                         'name': 'itemsrc_vend_uom',
1841                                         'type': 'string'
1842                                     },
1843                                     {
1844                                         'name': 'itemsrc_invvendoruomratio',
1845                                         'type': 'float'
1846                                     },
1847                                     {
1848                                         'name': 'itemsrc_minordqty',
1849                                         'type': 'float'
1850                                     },
1851                                     {
1852                                         'name': 'itemsrc_multordqty',
1853                                         'type': 'float'
1854                                     },
1855                                     {
1856                                         'name': 'itemsrc_leadtime',
1857                                         'type': 'int'
1858                                     },
1859                                     {
1860                                         'name': 'itemsrc_ranking',
1861                                         'type': 'int'
1862                                     },
1863                                     {
1864                                         'name': 'itemsrc_active',
1865                                         'type': 'int'
1866                                     },
1867                                     {
1868                                         'name': 'itemsrc_manuf_name',
1869                                         'type': 'string'
1870                                     },
1871                                     {
1872                                         'name': 'itemsrc_manuf_item_number',
1873                                         'type': 'string'
1874                                     },
1875                                     {
1876                                         'name': 'itemsrc_manuf_item_descrip',
1877                                         'type': 'string'
1878                                     },
1879                                     {
1880                                         'name': 'itemsrc_default',
1881                                         'type': 'int'
1882                                     },
1883                                     {
1884                                         'name': 'itemsrc_upccode',
1885                                         'type': 'string'
1886                                     }
1887                                 ],
1888                                 totalProperty : 'total'
1889                             },
1890                             '|xns' : 'Roo.data',
1891                             xtype : 'Store',
1892                             remoteSort : true,
1893                             sortInfo : { field : 'itemsrc_vend_id_vend_name', direction: 'ASC' },
1894                             xns : Roo.data,
1895                             listeners : {
1896                                 update : function (_self, record, operation)
1897                                    {
1898                                        Roo.log(operation);
1899                                          Roo.log(record);
1900                                       
1901                                        if (operation != 'commit') {
1902                                            return;
1903                                        }
1904                                        if (record.data.itemsrc_vend_id * 1 < 1) {
1905                                            return; // do not save.
1906                                        }
1907                                        if (record.data.itemsrc_id * 1 < 0) {
1908                                            return; // do not save. -- updating at present...
1909                                        }
1910                                        
1911                                        var p = Roo.apply({}, record.data);
1912                                        record.set('itemsrc_id', -1);    
1913                                        
1914                                        new Pman.Request({
1915                                            url : baseURL + '/Roo/Itemsrc',
1916                                            params : p,
1917                                            method : 'POST',
1918                                            success: function(res) {
1919                                                if (record.data.itemsrc_id *1  < 1) { 
1920                                                    record.set('itemsrc_id', res.data.itemsrc_id);
1921                                                }
1922                                            }
1923                                        });
1924                                        
1925                                        
1926                                    },
1927                                 beforeload : function (_self, o)
1928                                    {
1929                                        
1930                                        var id = 1 * _this.form.findField('item_id').getValue();
1931                                        if (!id) {
1932                                            this.removeAll();
1933                                            return false;
1934                                        }
1935                                        o.params.itemsrc_item_id = id;
1936                                    }
1937                             },
1938                             items : [
1939
1940                             ]
1941
1942                         },
1943                         footer : {
1944                             '|xns' : 'Roo',
1945                             pageSize : 25,
1946                             xtype : 'PagingToolbar',
1947                             emptyMsg : "No itemsrc found",
1948                             xns : Roo,
1949                             displayInfo : true,
1950                             displayMsg : "Displaying itemsrc{0} - {1} of {2}"
1951                         },
1952                         toolbar : {
1953                             '|xns' : 'Roo',
1954                             xtype : 'Toolbar',
1955                             xns : Roo,
1956                             items : [
1957                                 {
1958                                     '|xns' : 'Roo.Toolbar',
1959                                     text : "Add",
1960                                     xtype : 'Button',
1961                                     cls : 'x-btn-text-icon',
1962                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1963                                     xns : Roo.Toolbar,
1964                                     listeners : {
1965                                         click : function()
1966                                            {
1967                                                 
1968                                                Roo.log("add presed");
1969                                                 
1970                                                // work out last 
1971                                                var grid = _this.itemsrcgrid;
1972                                                 
1973                                                // uses form defaults or last row value.
1974                                                var nr = grid.ds.reader.newRow({
1975                                                         itemsrc_id : 0,
1976                                                    itemsrc_item_id : _this.form.findField('item_id').getValue(),
1977                                            
1978                                                     itemsrc_vend_id : 0,
1979                                                     itemsrc_vend_item_number : '',
1980                                                     itemsrc_vend_item_descrip : '',
1981                                                     itemsrc_comments           : '',
1982                                                     itemsrc_vend_uom  :           'EA',
1983                                                     itemsrc_invvendoruomratio : 1.0,
1984                                                     itemsrc_minordqty        : 0,
1985                                                     itemsrc_multordqty        : 0,
1986                                                     itemsrc_leadtime         :  30,
1987                                                     itemsrc_ranking         :   0,
1988                                                     itemsrc_active          :   true,
1989                                                     itemsrc_manuf_name       :  '',
1990                                                     itemsrc_manuf_item_number : '',
1991                                                     itemsrc_manuf_item_descrip: '',
1992                                                     itemsrc_default          : true,
1993                                                     itemsrc_upccode    : ''
1994                                                                    
1995                                                });
1996                                                grid.stopEditing();
1997                                                grid.ds.insert(0, nr); 
1998                                                grid.startEditing(0, 0); // type..
1999                                            
2000                                            }
2001                                     }
2002                                 }
2003                             ]
2004
2005                         },
2006                         '|xns' : 'Roo.grid',
2007                         autoExpandColumn : 'itemsrc_comments',
2008                         xtype : 'EditorGrid',
2009                         loadMask : true,
2010                         clicksToEdit : 1,
2011                         xns : Roo.grid,
2012                         colModel : [
2013                                  {
2014                                         editor : {
2015                                             field : {
2016                                                 store : {
2017                                                     proxy : {
2018                                                         '|xns' : 'Roo.data',
2019                                                         url : baseURL + '/Roo/vendinfo.php',
2020                                                         xtype : 'HttpProxy',
2021                                                         method : 'GET',
2022                                                         xns : Roo.data
2023                                                     },
2024                                                     reader : {
2025                                                         '|xns' : 'Roo.data',
2026                                                         id : 'id',
2027                                                         root : 'data',
2028                                                         xtype : 'JsonReader',
2029                                                         xns : Roo.data,
2030                                                         fields : [{"name":"id","type":"int"},{"name":"vend_name","type":"string"}],
2031                                                         totalProperty : 'total'
2032                                                     },
2033                                                     '|xns' : 'Roo.data',
2034                                                     xtype : 'Store',
2035                                                     remoteSort : true,
2036                                                     xns : Roo.data,
2037                                                     sortInfo : { direction : 'ASC', field: 'id' },
2038                                                     listeners : {
2039                                                         beforeload : function (_self, o){
2040                                                                o.params = o.params || {};
2041                                                                // set more here
2042                                                            }
2043                                                     },
2044                                                     items : [
2045
2046                                                     ]
2047
2048                                                 },
2049                                                 '|xns' : 'Roo.form',
2050                                                 listWidth : 400,
2051                                                 triggerAction : 'all',
2052                                                 forceSelection : true,
2053                                                 selectOnFocus : true,
2054                                                 pageSize : 20,
2055                                                 displayField : 'vend_name',
2056                                                 emptyText : "Select Vendor",
2057                                                 hiddenName : 'itemsrc_vend_id',
2058                                                 minChars : 2,
2059                                                 valueField : 'vend_id',
2060                                                 xtype : 'ComboBox',
2061                                                 allowBlank : false,
2062                                                 typeAhead : true,
2063                                                 editable : true,
2064                                                 width : 300,
2065                                                 xns : Roo.form,
2066                                                 name : 'itemsrc_vend_id_vend_name',
2067                                                 qtip : "Select vendinfo",
2068                                                 queryParam : 'q[search]',
2069                                                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{vend_name}</b> </div>',
2070                                                 loadingText : "Searching...",
2071                                                 items : [
2072
2073                                                 ]
2074
2075                                             },
2076                                             '|xns' : 'Roo.grid',
2077                                             xtype : 'GridEditor',
2078                                             xns : Roo.grid,
2079                                             items : [
2080
2081                                             ]
2082
2083                                         },
2084                                         '|xns' : 'Roo.grid',
2085                                         xtype : 'ColumnModel',
2086                                         width : 120,
2087                                         header : 'Vendor',
2088                                         renderer : function(v,x,r) { return String.format('{0}', r.data.itemsrc_vend_id_vend_name); },
2089                                         xns : Roo.grid,
2090                                         dataIndex : 'itemsrc_vend_id',
2091                                         items : [
2092
2093                                         ]
2094
2095                                     },
2096 {
2097                                         editor : {
2098                                             field : {
2099                                                 '|xns' : 'Roo.form',
2100                                                 xtype : 'TextField',
2101                                                 xns : Roo.form
2102                                             },
2103                                             '|xns' : 'Roo.grid',
2104                                             xtype : 'GridEditor',
2105                                             xns : Roo.grid,
2106                                             items : [
2107
2108                                             ]
2109
2110                                         },
2111                                         '|xns' : 'Roo.grid',
2112                                         xtype : 'ColumnModel',
2113                                         width : 100,
2114                                         header : 'Vendor Ref#',
2115                                         renderer : function(v) { return String.format('{0}', v); },
2116                                         xns : Roo.grid,
2117                                         dataIndex : 'itemsrc_vend_item_number',
2118                                         items : [
2119
2120                                         ]
2121
2122                                     },
2123 {
2124                                         editor : {
2125                                             field : {
2126                                                 '|xns' : 'Roo.form',
2127                                                 xtype : 'TextField',
2128                                                 xns : Roo.form
2129                                             },
2130                                             '|xns' : 'Roo.grid',
2131                                             xtype : 'GridEditor',
2132                                             xns : Roo.grid,
2133                                             items : [
2134
2135                                             ]
2136
2137                                         },
2138                                         '|xns' : 'Roo.grid',
2139                                         xtype : 'ColumnModel',
2140                                         width : 200,
2141                                         header : 'Comments',
2142                                         renderer : function(v) { return String.format('{0}', v); },
2143                                         xns : Roo.grid,
2144                                         dataIndex : 'itemsrc_comments',
2145                                         items : [
2146
2147                                         ]
2148
2149                                     },
2150 {
2151                                         '|xns' : 'Roo.grid',
2152                                         xtype : 'ColumnModel',
2153                                         width : 50,
2154                                         header : 'UOM',
2155                                         renderer : function(v) { return String.format('{0}', v); },
2156                                         xns : Roo.grid,
2157                                         dataIndex : 'itemsrc_vend_uom'
2158                                     },
2159 {
2160                                         editor : {
2161                                             field : {
2162                                                 '|xns' : 'Roo.form',
2163                                                 minValue : 0,
2164                                                 xtype : 'NumberField',
2165                                                 decimalPrecision : 0,
2166                                                 xns : Roo.form
2167                                             },
2168                                             '|xns' : 'Roo.grid',
2169                                             xtype : 'GridEditor',
2170                                             xns : Roo.grid,
2171                                             items : [
2172
2173                                             ]
2174
2175                                         },
2176                                         '|xns' : 'Roo.grid',
2177                                         align : 'right',
2178                                         xtype : 'ColumnModel',
2179                                         header : 'Min Qty',
2180                                         width : 50,
2181                                         renderer : function(v) { return String.format('{0}', v); },
2182                                         xns : Roo.grid,
2183                                         dataIndex : 'itemsrc_minordqty',
2184                                         items : [
2185
2186                                         ]
2187
2188                                     },
2189 {
2190                                         editor : {
2191                                             field : {
2192                                                 '|xns' : 'Roo.form',
2193                                                 minValue : 0,
2194                                                 xtype : 'NumberField',
2195                                                 decimalPrecision : 0,
2196                                                 xns : Roo.form
2197                                             },
2198                                             '|xns' : 'Roo.grid',
2199                                             xtype : 'GridEditor',
2200                                             xns : Roo.grid,
2201                                             items : [
2202
2203                                             ]
2204
2205                                         },
2206                                         '|xns' : 'Roo.grid',
2207                                         align : 'right',
2208                                         xtype : 'ColumnModel',
2209                                         header : 'Lead time',
2210                                         width : 75,
2211                                         renderer : function(v) { return String.format('{0}', v); },
2212                                         xns : Roo.grid,
2213                                         dataIndex : 'itemsrc_leadtime',
2214                                         items : [
2215
2216                                         ]
2217
2218                                     },
2219 {
2220                                         '|xns' : 'Roo.grid',
2221                                         xtype : 'ColumnModel',
2222                                         width : 50,
2223                                         header : 'Active',
2224                                         renderer : function(v) { return String.format('{0}', v); },
2225                                         xns : Roo.grid,
2226                                         dataIndex : 'itemsrc_active'
2227                                     }
2228                         ],
2229                         listeners : {
2230                                 rowdblclick : function (_self, rowIndex, e)
2231                                    {
2232                                        if (!_this.dialog) return;
2233                                        _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
2234                                            _this.grid.footer.onClick('first');
2235                                        }); 
2236                                    },
2237                                 render : function() 
2238                                    {
2239                                        _this.itemsrcgrid = this; 
2240                                        //_this.dialog = Pman.Dialog.FILL_IN
2241                                        
2242                                    },
2243                                 afteredit : function (e)
2244                                    {
2245                                        e.record.commit();
2246                                    }
2247                         },
2248                         items : [
2249
2250                         ]
2251
2252                     },
2253                     '|xns' : 'Roo',
2254                     region : 'center',
2255                     fitToframe : true,
2256                     background : true,
2257                     title : "Suppliers",
2258                     xtype : 'GridPanel',
2259                     fitContainer : true,
2260                     xns : Roo,
2261                     tableName : 'itemsrc',
2262                     listeners : {
2263                         activate : function() {
2264                                _this.itemsrcpanel = this;
2265                                if (_this.itemsrcgrid) {
2266                                    _this.itemsrcgrid.footer.onClick('first');
2267                                }
2268                            }
2269                     },
2270                     items : [
2271
2272                     ]
2273
2274                 },
2275                 {
2276                     grid : {
2277                         dataSource : {
2278                             proxy : {
2279                                 '|xns' : 'Roo.data',
2280                                 url : baseURL + '/Roo/events.php',
2281                                 method : 'GET',
2282                                 xtype : 'HttpProxy',
2283                                 xns : Roo.data
2284                             },
2285                             reader : {
2286                                 '|xns' : 'Roo.data',
2287                                 id : 'id',
2288                                 root : 'data',
2289                                 xtype : 'JsonReader',
2290                                 fields : [
2291                                     {
2292                                         'name': 'event_when',
2293                                         'type': 'date'
2294                                     },
2295                                     {
2296                                         'name': 'action',
2297                                         'type': 'string'
2298                                     },
2299                                     {
2300                                         'name': 'ipaddr',
2301                                         'type': 'string'
2302                                     },
2303                                     {
2304                                         'name': 'person_id_name',
2305                                         'type': 'string'
2306                                     },
2307                                     {
2308                                         'name': 'remarks',
2309                                         'type': 'string'
2310                                     }
2311                                 ],
2312                                 xns : Roo.data,
2313                                 totalProperty : 'total'
2314                             },
2315                             '|xns' : 'Roo.data',
2316                             xtype : 'Store',
2317                             remoteSort : true,
2318                             sortInfo : { field : 'event_when', direction: 'DESC' },
2319                             xns : Roo.data,
2320                             listeners : {
2321                                 beforeload : function (_self, options)
2322                                    {
2323                                        options.params = options.params || {};
2324                                        
2325                                        options.params.on_table = 'item';
2326                                        options.params.on_id = _this.form.findField('item_id').getValue();
2327                                    }
2328                             },
2329                             items : [
2330
2331                             ]
2332
2333                         },
2334                         footer : {
2335                             '|xns' : 'Roo',
2336                             pageSize : 25,
2337                             xtype : 'PagingToolbar',
2338                             emptyMsg : "No Events found",
2339                             xns : Roo,
2340                             displayMsg : "Displaying events{0} - {1} of {2}",
2341                             displayInfo : true
2342                         },
2343                         '|xns' : 'Roo.grid',
2344                         autoExpandColumn : 'remarks',
2345                         xtype : 'Grid',
2346                         loadMask : true,
2347                         xns : Roo.grid,
2348                         colModel : [
2349                                  {
2350                                         '|xns' : 'Roo.grid',
2351                                         xtype : 'ColumnModel',
2352                                         width : 120,
2353                                         header : 'Changed',
2354                                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
2355                                         xns : Roo.grid,
2356                                         dataIndex : 'event_when'
2357                                     },
2358 {
2359                                         '|xns' : 'Roo.grid',
2360                                         xtype : 'ColumnModel',
2361                                         width : 200,
2362                                         header : 'Action',
2363                                         renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); },
2364                                         xns : Roo.grid,
2365                                         dataIndex : 'action'
2366                                     },
2367 {
2368                                         '|xns' : 'Roo.grid',
2369                                         xtype : 'ColumnModel',
2370                                         width : 200,
2371                                         header : 'IP Address',
2372                                         renderer : function(v) { return String.format('{0}', v); },
2373                                         xns : Roo.grid,
2374                                         dataIndex : 'ipaddr'
2375                                     },
2376 {
2377                                         '|xns' : 'Roo.grid',
2378                                         xtype : 'ColumnModel',
2379                                         width : 75,
2380                                         header : 'Who',
2381                                         renderer : function(v) { return String.format('{0}', v); },
2382                                         xns : Roo.grid,
2383                                         dataIndex : 'person_id_name'
2384                                     },
2385 {
2386                                         '|xns' : 'Roo.grid',
2387                                         xtype : 'ColumnModel',
2388                                         width : 200,
2389                                         header : 'Notes',
2390                                         renderer : function(v) { return String.format('{0}', v); },
2391                                         xns : Roo.grid,
2392                                         dataIndex : 'remarks'
2393                                     }
2394                         ],
2395                         listeners : {
2396                                 render : function() 
2397                                    {
2398                                        _this.hgrid = this; 
2399                                        if (_this.hpanel.active) {
2400                                           this.footer.onClick('first');
2401                                        }
2402                                    }
2403                         },
2404                         items : [
2405
2406                         ]
2407
2408                     },
2409                     '|xns' : 'Roo',
2410                     region : 'center',
2411                     fitToframe : true,
2412                     background : true,
2413                     title : "History",
2414                     xtype : 'GridPanel',
2415                     fitContainer : true,
2416                     xns : Roo,
2417                     tableName : 'events',
2418                     listeners : {
2419                         activate : function() {
2420                                _this.hpanel = this;
2421                                if (_this.hgrid) {
2422                                    _this.hgrid.footer.onClick('first');
2423                                }
2424                            }
2425                     },
2426                     items : [
2427
2428                     ]
2429
2430                 }
2431             ]
2432
2433         });
2434     }
2435 };