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/item.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":"item_number","type":"string"}
969                                             ],
970                                             xns : Roo.data,
971                                             totalProperty : 'total'
972                                         },
973                                         '|xns' : 'Roo.data',
974                                         xtype : 'Store',
975                                         remoteSort : true,
976                                         sortInfo : { direction : 'ASC', field: 'item_number' },
977                                         xns : Roo.data,
978                                         listeners : {
979                                                 beforeload : function (_self, o){
980                                                        o.params = o.params || {};
981                                                        
982                                                        o.params.item_active = 1;
983                                                        o.params['!item_type'] = 'K';
984                                                    }
985                                         },
986                                         items : [
987
988                                         ]
989
990                                     },
991                                     '|xns' : 'Roo.bootstrap',
992                                     alwaysQuery : true,
993                                     triggerAction : 'all',
994                                     fieldLabel : 'Item',
995                                     forceSelection : true,
996                                     selectOnFocus : true,
997                                     pageSize : 20,
998                                     displayField : 'item_number',
999                                     emptyText : "Select item",
1000                                     minChars : 2,
1001                                     valueField : 'id',
1002                                     xtype : 'ComboBox',
1003                                     allowBlank : true,
1004                                     typeAhead : true,
1005                                     editable : true,
1006                                     width : 200,
1007                                     xns : Roo.bootstrap,
1008                                     qtip : "Select item",
1009                                     queryParam : 'query[number_or_name]',
1010                                     tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{item_number}</b> </div>',
1011                                     loadingText : "Searching...",
1012                                     listeners : {
1013                                         render : function (_self)
1014                                            {
1015                                                _this.partsBox = _self;
1016                                            },
1017                                         select : function (combo, record, index)
1018                                            {
1019                                                var item_id = _this.form.findField('item_id').getValue() * 1;
1020                                                
1021                                                if(typeof(record) == 'undefined' || !record || record.data.id * 1 < 1 || item_id < 1){
1022                                                    return;
1023                                                }
1024                                                
1025                                                var err = false;
1026                                            
1027                                                _this.partsgrid.ds.each(function(d){
1028                                                    if(record.data.item_id == d.data.bomitem_item_id){
1029                                                        err = true;
1030                                                    }
1031                                                });
1032                                            
1033                                                if(err){
1034                                                    Roo.MessageBox.alert('Error', record.data.item_number + ' already exists!');
1035                                                    _this.partsBox.reset();
1036                                                    return;
1037                                                }
1038                                                
1039                                                new Pman.Request({
1040                                                    url : baseURL + '/Roo/bomitem.php',
1041                                                    method : 'POST',
1042                                                    params : {
1043                                                        bomitem_parent_item_id : item_id,
1044                                                        bomitem_item_id : record.data.item_id
1045                                                    }, 
1046                                                    success : function(res) {
1047                                                        _this.partsBox.reset();
1048                                                        _this.partsgrid.footer.onClick('first');
1049                                                    }
1050                                                }); 
1051                                            }
1052                                     },
1053                                     items : [
1054
1055                                     ]
1056
1057                                 },
1058                                 {
1059                                     '|xns' : 'Roo.Toolbar',
1060                                     xtype : 'Fill',
1061                                     xns : Roo.Toolbar
1062                                 },
1063                                 {
1064                                     '|xns' : 'Roo',
1065                                     text : "Remove",
1066                                     xtype : 'Button',
1067                                     cls : 'x-btn-text-icon',
1068                                     icon : rootURL + '/Pman/templates/images/trash.gif',
1069                                     xns : Roo,
1070                                     listeners : {
1071                                         click : function ()
1072                                            {
1073                                                var sel = _this.partsgrid.getSelectionModel().getSelectedCell();
1074                                                
1075                                                if(!sel || !sel.length){
1076                                                    Roo.MessageBox.alert("Error", "Please select a item from below list");
1077                                                    return;
1078                                                }
1079                                                
1080                                                var d = _this.partsgrid.ds.getAt(sel[0]);      
1081                                              
1082                                                if(d.data.bomitem_id * 1 < 1){
1083                                                    Roo.MessageBox.alert("Error", "Invaild selection");
1084                                                    return;
1085                                                }
1086                                                
1087                                                new Pman.Request({
1088                                                    url : baseURL + '/Roo/bomitem.php',
1089                                                    method : 'POST',
1090                                                    params : {
1091                                                        _delete : d.data.bomitem_id
1092                                                    }, 
1093                                                    success : function(res) {
1094                                                        _this.partsgrid.footer.onClick('first');
1095                                                    }
1096                                                }); 
1097                                               
1098                                            }
1099                                     }
1100                                 }
1101                             ]
1102
1103                         },
1104                         dataSource : {
1105                             proxy : {
1106                                 '|xns' : 'Roo.data',
1107                                 url : baseURL + '/Roo/bomitem.php',
1108                                 xtype : 'HttpProxy',
1109                                 method : 'GET',
1110                                 xns : Roo.data
1111                             },
1112                             reader : {
1113                                 '|xns' : 'Roo.data',
1114                                 id : 'bom_id',
1115                                 root : 'data',
1116                                 xtype : 'JsonReader',
1117                                 fields : [
1118                                     {
1119                                         'name': 'bomitem_id',
1120                                         'type': 'int'
1121                                     }
1122                                 ],
1123                                 xns : Roo.data,
1124                                 totalProperty : 'total'
1125                             },
1126                             '|xns' : 'Roo.data',
1127                             xtype : 'Store',
1128                             remoteSort : true,
1129                             sortInfo : { field : 'bomitem_item_id_item_name', direction: 'ASC' },
1130                             xns : Roo.data,
1131                             listeners : {
1132                                 beforeload : function (_self, o)
1133                                    {
1134                                       o.params = o.params || {};
1135                                       
1136                                       var id  = _this.form.findField('item_id').getValue() * 1;
1137                                       if(id < 1){
1138                                            return false;
1139                                       }
1140                                       
1141                                       o.params.bom_parent_item_id = id;
1142                                    }
1143                             },
1144                             items : [
1145
1146                             ]
1147
1148                         },
1149                         footer : {
1150                             '|xns' : 'Roo',
1151                             pageSize : 50,
1152                             xtype : 'PagingToolbar',
1153                             emptyMsg : "Nothing found",
1154                             xns : Roo,
1155                             displayMsg : "Displaying parts {0} - {1} of {2}",
1156                             displayInfo : true
1157                         },
1158                         '|xns' : 'Roo.grid',
1159                         autoExpandColumn : 'bomitem_item_id_item_descrip1',
1160                         xtype : 'EditorGrid',
1161                         loadMask : true,
1162                         clicksToEdit : 1,
1163                         xns : Roo.grid,
1164                         colModel : [
1165                                  {
1166                                         '|xns' : 'Roo.grid',
1167                                         xtype : 'ColumnModel',
1168                                         header : 'Name',
1169                                         width : 150,
1170                                         renderer : function(v) { return String.format('{0}', v); },
1171                                         xns : Roo.grid,
1172                                         dataIndex : 'bomitem_item_id_item_number'
1173                                     },
1174 {
1175                                         '|xns' : 'Roo.grid',
1176                                         xtype : 'ColumnModel',
1177                                         header : 'Description',
1178                                         width : 150,
1179                                         renderer : function(v) { return String.format('{0}', v); },
1180                                         xns : Roo.grid,
1181                                         dataIndex : 'bomitem_item_id_item_descrip1'
1182                                     },
1183 {
1184                                         editor : {
1185                                             field : {
1186                                                 '|xns' : 'Roo.form',
1187                                                 xtype : 'NumberField',
1188                                                 allowDecimals : false,
1189                                                 xns : Roo.form
1190                                             },
1191                                             '|xns' : 'Roo.grid',
1192                                             xtype : 'GridEditor',
1193                                             xns : Roo.grid,
1194                                             items : [
1195
1196                                             ]
1197
1198                                         },
1199                                         '|xns' : 'Roo.grid',
1200                                         xtype : 'ColumnModel',
1201                                         align : 'right',
1202                                         header : 'Qty',
1203                                         width : 100,
1204                                         renderer : function(v) { return String.format('{0}', v); },
1205                                         xns : Roo.grid,
1206                                         dataIndex : 'bomitem_qtyper',
1207                                         items : [
1208
1209                                         ]
1210
1211                                     }
1212                         ],
1213                         listeners : {
1214                                 beforeedit : function (e)
1215                                    {
1216                                        Roo.log('before');
1217                                        Roo.log(e);
1218                                        if(e.field != 'ipshead_ipsitem_price'){
1219                                            return false;
1220                                        }
1221                                        
1222                                    },
1223                                 render : function() 
1224                                    {
1225                                        _this.partsgrid = this; 
1226                                        //_this.dialog = Pman.Dialog.FILL_IN
1227                                        if (_this.partspanel.active) {
1228                                           this.footer.onClick('first');
1229                                        }
1230                                    },
1231                                 afteredit : function (e)
1232                                    {
1233                                        Roo.log('after');
1234                                        Roo.log(e);
1235                                        if(e.originalValue == e.value){
1236                                            return false;
1237                                        }
1238                                        return false;
1239                                        
1240                                        
1241                                        var id = _this.form.findField('item_id').getValue() * 1;
1242                                        if(id < 1){
1243                                            return false;
1244                                        }
1245                                        
1246                                        new Pman.Request({
1247                                            method : 'POST',
1248                                            url : baseURL + '/Roo/ipsiteminfo',
1249                                            mask : 'Saving',
1250                                            params : {
1251                                                ipsitem_ipshead_id : e.record.data.ipshead_id,
1252                                                ipsitem_item_id : id,
1253                                                ipsitem_price : e.record.data.ipshead_ipsitem_price,
1254                                                ipsitem_id : e.record.data.ipshead_ipsitem_id
1255                                            }
1256                                        
1257                                        });
1258                                            
1259                                             
1260                                            
1261                                            
1262                                    }
1263                         },
1264                         items : [
1265
1266                         ]
1267
1268                     },
1269                     '|xns' : 'Roo',
1270                     background : true,
1271                     region : 'center',
1272                     fitToframe : true,
1273                     title : "Item Parts",
1274                     xtype : 'GridPanel',
1275                     fitContainer : true,
1276                     xns : Roo,
1277                     tableName : 'bomitem',
1278                     listeners : {
1279                         activate : function() {
1280                                _this.partspanel = this;
1281                                
1282                                try { if (MODULE.isBuilder) {
1283                                    return;
1284                                } } catch(e) { }
1285                                
1286                                var id = _this.form.findField('item_id').getValue() * 1;
1287                                if (id < 1) {
1288                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding parts");
1289                                    _this.dialog.layout.getRegion('center').showPanel(0);
1290                                    return;
1291                                }
1292                                
1293                                var type = _this.form.findField('item_type').getValue();
1294                                
1295                                if(!type.length || type != 'K'){
1296                                    Roo.MessageBox.alert("Error", "Can't add parts to non-kit item");
1297                                    _this.dialog.layout.getRegion('center').showPanel(0);
1298                                    return;
1299                                }
1300                                
1301                                if (_this.partsgrid) {
1302                                    _this.partsgrid.footer.onClick('first');
1303                                
1304                                 }
1305                            }
1306                     },
1307                     items : [
1308
1309                     ]
1310
1311                 },
1312                 {
1313                     grid : {
1314                         dataSource : {
1315                             reader : {
1316                                 '|xns' : 'Roo.data',
1317                                 id : 'id',
1318                                 root : 'data',
1319                                 xtype : 'JsonReader',
1320                                 fields : [
1321                                     {
1322                                         'name': 'id',
1323                                         'type': 'int'
1324                                     },
1325                                     {
1326                                         'name': 'filename',
1327                                         'type': 'string'
1328                                     },
1329                                     {
1330                                         'name': 'ontable',
1331                                         'type': 'string'
1332                                     },
1333                                     {
1334                                         'name': 'onid',
1335                                         'type': 'int'
1336                                     },
1337                                     {
1338                                         'name': 'mimetype',
1339                                         'type': 'string'
1340                                     },
1341                                     {
1342                                         'name': 'width',
1343                                         'type': 'int'
1344                                     },
1345                                     {
1346                                         'name': 'height',
1347                                         'type': 'int'
1348                                     },
1349                                     {
1350                                         'name': 'filesize',
1351                                         'type': 'int'
1352                                     },
1353                                     {
1354                                         'name': 'displayorder',
1355                                         'type': 'int'
1356                                     },
1357                                     {
1358                                         'name': 'language',
1359                                         'type': 'string'
1360                                     },
1361                                     {
1362                                         'name': 'parent_image_id',
1363                                         'type': 'int'
1364                                     },
1365                                     {
1366                                         'name': 'created',
1367                                         'type': 'date',
1368                                         'dateFormat' : 'Y-m-d H:i:s'
1369                                     },
1370                                     {
1371                                         'name': 'imgtype',
1372                                         'type': 'string'
1373                                     },
1374                                     {
1375                                         'name': 'linkurl',
1376                                         'type': 'string'
1377                                     },
1378                                     {
1379                                         'name': 'descript',
1380                                         'type': 'string'
1381                                     },
1382                                     {
1383                                         'name': 'title',
1384                                         'type': 'string'
1385                                     }
1386                                 ],
1387                                 xns : Roo.data,
1388                                 totalProperty : 'total'
1389                             },
1390                             proxy : {
1391                                 '|xns' : 'Roo.data',
1392                                 url : baseURL + '/Roo/Images.php',
1393                                 xtype : 'HttpProxy',
1394                                 method : 'GET',
1395                                 xns : Roo.data
1396                             },
1397                             '|xns' : 'Roo.data',
1398                             xtype : 'Store',
1399                             remoteSort : true,
1400                             sortInfo : { field: 'created' , direction: 'DESC' },
1401                             xns : Roo.data,
1402                             listeners : {
1403                                 beforeload : function (_self, o)
1404                                    {
1405                                        o.params = o.params || {};
1406                                        
1407                                        var id = _this.form.findField('item_id').getValue();
1408                                        
1409                                        if(id * 1 < 1){
1410                                            return false;
1411                                        }
1412                                        
1413                                        o.params.onid = id;
1414                                        o.params.ontable = 'item';
1415                                        
1416                                    }
1417                             },
1418                             items : [
1419
1420                             ]
1421
1422                         },
1423                         footer : {
1424                             '|xns' : 'Roo',
1425                             pageSize : 25,
1426                             xtype : 'PagingToolbar',
1427                             emptyMsg : "No Images found",
1428                             xns : Roo,
1429                             displayInfo : true,
1430                             displayMsg : "Displaying Images  {0} - {1} of {2}"
1431                         },
1432                         toolbar : {
1433                             '|xns' : 'Roo',
1434                             xtype : 'Toolbar',
1435                             xns : Roo,
1436                             items : [
1437                                 {
1438                                     '|xns' : 'Roo.Toolbar',
1439                                     text : "Add",
1440                                     xtype : 'Button',
1441                                     cls : 'x-btn-text-icon',
1442                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1443                                     xns : Roo.Toolbar,
1444                                     listeners : {
1445                                         click : function()
1446                                            {
1447                                                Pman.Dialog.Image.show({
1448                                                    id : 0, 
1449                                                    ontable: 'item',
1450                                                    onid: _this.form.findField('item_id').getValue() * 1,
1451                                                    imgtype : ''
1452                                                }, function(data){
1453                                                    if (!data) { return; } 
1454                                                    _this.grid.footer.onClick('first');
1455                                                }); 
1456                                            
1457                                            }
1458                                     }
1459                                 },
1460                                 {
1461                                     '|xns' : 'Roo.Toolbar',
1462                                     text : "Delete",
1463                                     xtype : 'Button',
1464                                     cls : 'x-btn-text-icon',
1465                                     icon : rootURL + '/Pman/templates/images/trash.gif',
1466                                     xns : Roo.Toolbar,
1467                                     listeners : {
1468                                         click : function()
1469                                            {
1470                                                Pman.genericDelete(_this, 'Images'); 
1471                                            }
1472                                     }
1473                                 }
1474                             ]
1475
1476                         },
1477                         '|xns' : 'Roo.grid',
1478                         autoExpandColumn : 'id',
1479                         xtype : 'Grid',
1480                         loadMask : true,
1481                         xns : Roo.grid,
1482                         colModel : [
1483                                  {
1484                                         '|xns' : 'Roo.grid',
1485                                         xtype : 'ColumnModel',
1486                                         sortable : true,
1487                                         header : 'Created',
1488                                         width : 200,
1489                                         renderer : function(v,x,r) {
1490                                                return String.format('{0}<br/><i>{1}</i><br/>{2}<br/><i>{3}x{4}</i>',
1491                                                     v.format('d/M/Y'), r.data.mimetype, r.data.filename,
1492                                             r.data.width, r.data.height
1493                                             ); 
1494                                         },
1495                                         xns : Roo.grid,
1496                                         dataIndex : 'created'
1497                                     },
1498 {
1499                                         '|xns' : 'Roo.grid',
1500                                         xtype : 'ColumnModel',
1501                                         width : 100,
1502                                         header : 'Image',
1503                                         renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.filename); },
1504                                         xns : Roo.grid,
1505                                         dataIndex : 'id'
1506                                     }
1507                         ],
1508                         listeners : {
1509                                 rowdblclick : function (_self, rowIndex, e)
1510                                    {
1511                                      
1512                                       var s =  _self.getDataSource().getAt(rowIndex);
1513                                       new Pman.Download({
1514                                            url : baseURL + '/Images/Download/' + s.data.id
1515                                        });
1516                                       
1517                                    },
1518                                 render : function() { 
1519                                        _this.grid = this; 
1520                                    
1521                                        if (_this.panel.active) {
1522                                           this.footer.onClick('first');
1523                                        }
1524                                    }
1525                         },
1526                         items : [
1527
1528                         ]
1529
1530                     },
1531                     '|xns' : 'Roo',
1532                     region : 'center',
1533                     fitToframe : true,
1534                     background : true,
1535                     title : "Reference Files",
1536                     xtype : 'GridPanel',
1537                     fitContainer : true,
1538                     xns : Roo,
1539                     tableName : 'Images',
1540                     listeners : {
1541                         activate : function() {
1542                                _this.panel = this;
1543                                
1544                                try { if (MODULE.isBuilder) {
1545                                    return;
1546                                } } catch(e) { }
1547                                
1548                                var id = _this.form.findField('item_id').getValue() * 1;
1549                                if (id < 1) {
1550                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding image");
1551                                    _this.dialog.layout.getRegion('center').showPanel(0);
1552                                    return;
1553                                }
1554                                
1555                                if (_this.grid) {
1556                                    _this.grid.footer.onClick('first');
1557                                
1558                                 }
1559                            }
1560                     },
1561                     items : [
1562
1563                     ]
1564
1565                 },
1566                 {
1567                     grid : {
1568                         dataSource : {
1569                             proxy : {
1570                                 '|xns' : 'Roo.data',
1571                                 url : baseURL + '/Roo/ipshead.php',
1572                                 method : 'GET',
1573                                 xtype : 'HttpProxy',
1574                                 xns : Roo.data
1575                             },
1576                             reader : {
1577                                 '|xns' : 'Roo.data',
1578                                 id : 'ipshead_id',
1579                                 root : 'data',
1580                                 xtype : 'JsonReader',
1581                                 fields : [
1582                                     {
1583                                         'name': 'ipshead_id',
1584                                         'type': 'int'
1585                                     },
1586                                     {
1587                                         'name': 'ipshead_name',
1588                                         'type': 'string'
1589                                     }
1590                                 ],
1591                                 xns : Roo.data,
1592                                 totalProperty : 'total'
1593                             },
1594                             '|xns' : 'Roo.data',
1595                             xtype : 'Store',
1596                             remoteSort : true,
1597                             sortInfo : { field : 'ipshead_id', direction: 'ASC' },
1598                             xns : Roo.data,
1599                             listeners : {
1600                                 beforeload : function (_self, o)
1601                                    {
1602                                       o.params = o.params || {};
1603                                       
1604                                       var id  = _this.form.findField('item_id').getValue() * 1;
1605                                       if(id < 1){
1606                                            return false;
1607                                       }
1608                                       
1609                                       o.params._with_item = id;
1610                                    }
1611                             },
1612                             items : [
1613
1614                             ]
1615
1616                         },
1617                         footer : {
1618                             '|xns' : 'Roo',
1619                             pageSize : 50,
1620                             xtype : 'PagingToolbar',
1621                             emptyMsg : "Nothing found",
1622                             xns : Roo,
1623                             displayMsg : "Displaying records {0} - {1} of {2}",
1624                             displayInfo : true
1625                         },
1626                         '|xns' : 'Roo.grid',
1627                         autoExpandColumn : 'ipshead_descrip',
1628                         xtype : 'EditorGrid',
1629                         loadMask : true,
1630                         clicksToEdit : 1,
1631                         xns : Roo.grid,
1632                         colModel : [
1633                                  {
1634                                         '|xns' : 'Roo.grid',
1635                                         xtype : 'ColumnModel',
1636                                         width : 150,
1637                                         header : 'Name',
1638                                         renderer : function(v) { return String.format('{0}', v); },
1639                                         xns : Roo.grid,
1640                                         dataIndex : 'ipshead_name'
1641                                     },
1642 {
1643                                         '|xns' : 'Roo.grid',
1644                                         xtype : 'ColumnModel',
1645                                         width : 150,
1646                                         header : 'Description',
1647                                         renderer : function(v) { return String.format('{0}', v); },
1648                                         xns : Roo.grid,
1649                                         dataIndex : 'ipshead_descrip'
1650                                     },
1651 {
1652                                         '|xns' : 'Roo.grid',
1653                                         xtype : 'ColumnModel',
1654                                         width : 100,
1655                                         header : 'Currency',
1656                                         renderer : function(v) { return String.format('{0}', v); },
1657                                         xns : Roo.grid,
1658                                         dataIndex : 'ipshead_curr_id_curr_name'
1659                                     },
1660 {
1661                                         editor : {
1662                                             field : {
1663                                                 '|xns' : 'Roo.form',
1664                                                 xtype : 'NumberField',
1665                                                 cls : 'align-right',
1666                                                 decimalPrecision : 2,
1667                                                 xns : Roo.form
1668                                             },
1669                                             '|xns' : 'Roo.grid',
1670                                             xtype : 'GridEditor',
1671                                             xns : Roo.grid,
1672                                             items : [
1673
1674                                             ]
1675
1676                                         },
1677                                         '|xns' : 'Roo.grid',
1678                                         align : 'right',
1679                                         xtype : 'ColumnModel',
1680                                         header : 'Price',
1681                                         width : 120,
1682                                         renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
1683                                         xns : Roo.grid,
1684                                         dataIndex : 'ipshead_ipsitem_price',
1685                                         items : [
1686
1687                                         ]
1688
1689                                     }
1690                         ],
1691                         listeners : {
1692                                 beforeedit : function (e)
1693                                    {
1694                                        if(e.field != 'ipshead_ipsitem_price'){
1695                                            return false;
1696                                        }
1697                                        
1698                                    },
1699                                 render : function() 
1700                                    {
1701                                        _this.lgrid = this; 
1702                                        //_this.dialog = Pman.Dialog.FILL_IN
1703                                        if (_this.lpanel.active) {
1704                                           this.footer.onClick('first');
1705                                        }
1706                                    },
1707                                 afteredit : function (e)
1708                                    {
1709                                        if(e.originalValue == e.value){
1710                                            return false;
1711                                        }
1712                                        
1713                                        var id = _this.form.findField('item_id').getValue() * 1;
1714                                        if(id < 1){
1715                                            return false;
1716                                        }
1717                                        
1718                                        new Pman.Request({
1719                                            method : 'POST',
1720                                            url : baseURL + '/Roo/ipsiteminfo',
1721                                            mask : 'Saving',
1722                                            params : {
1723                                                ipsitem_ipshead_id : e.record.data.ipshead_id,
1724                                                ipsitem_item_id : id,
1725                                                ipsitem_price : e.record.data.ipshead_ipsitem_price,
1726                                                ipsitem_id : e.record.data.ipshead_ipsitem_id
1727                                            }
1728                                        
1729                                        });
1730                                            
1731                                             
1732                                            
1733                                            
1734                                    }
1735                         },
1736                         items : [
1737
1738                         ]
1739
1740                     },
1741                     '|xns' : 'Roo',
1742                     region : 'center',
1743                     fitToframe : true,
1744                     background : true,
1745                     title : "Price List",
1746                     xtype : 'GridPanel',
1747                     fitContainer : true,
1748                     xns : Roo,
1749                     tableName : 'ipshead',
1750                     listeners : {
1751                         activate : function() {
1752                                _this.lpanel = this;
1753                                
1754                                try { if (MODULE.isBuilder) {
1755                                    return;
1756                                } } catch(e) { }
1757                                
1758                                var id = _this.form.findField('item_id').getValue() * 1;
1759                                if (id < 1) {
1760                                    Roo.MessageBox.alert("Save First", "Save the item first, before adding image");
1761                                    _this.dialog.layout.getRegion('center').showPanel(0);
1762                                    return;
1763                                }
1764                                
1765                                if (_this.lgrid) {
1766                                    _this.lgrid.footer.onClick('first');
1767                                
1768                                 }
1769                            }
1770                     },
1771                     items : [
1772
1773                     ]
1774
1775                 },
1776                 {
1777                     grid : {
1778                         dataSource : {
1779                             proxy : {
1780                                 '|xns' : 'Roo.data',
1781                                 url : baseURL + '/Roo/itemsrc.php',
1782                                 xtype : 'HttpProxy',
1783                                 method : 'GET',
1784                                 xns : Roo.data
1785                             },
1786                             reader : {
1787                                 '|xns' : 'Roo.data',
1788                                 id : 'id',
1789                                 root : 'data',
1790                                 xtype : 'JsonReader',
1791                                 xns : Roo.data,
1792                                 fields : [
1793                                     {
1794                                         'name': 'itemsrc_id',
1795                                         'type': 'int'
1796                                     },
1797                                     {
1798                                         'name': 'itemsrc_item_id',
1799                                         'type': 'int'
1800                                     },
1801                                     {
1802                                         'name': 'itemsrc_item_id',
1803                                         'type': 'int'
1804                                     },
1805                                     {
1806                                         'name': 'itemsrc_vend_id',
1807                                         'type': 'int'
1808                                     },
1809                                     {
1810                                         'name': 'itemsrc_vend_id',
1811                                         'type': 'int'
1812                                     },
1813                                     {
1814                                         'name': 'itemsrc_vend_item_number',
1815                                         'type': 'string'
1816                                     },
1817                                     {
1818                                         'name': 'itemsrc_vend_item_descrip',
1819                                         'type': 'string'
1820                                     },
1821                                     {
1822                                         'name': 'itemsrc_comments',
1823                                         'type': 'string'
1824                                     },
1825                                     {
1826                                         'name': 'itemsrc_vend_uom',
1827                                         'type': 'string'
1828                                     },
1829                                     {
1830                                         'name': 'itemsrc_invvendoruomratio',
1831                                         'type': 'float'
1832                                     },
1833                                     {
1834                                         'name': 'itemsrc_minordqty',
1835                                         'type': 'float'
1836                                     },
1837                                     {
1838                                         'name': 'itemsrc_multordqty',
1839                                         'type': 'float'
1840                                     },
1841                                     {
1842                                         'name': 'itemsrc_leadtime',
1843                                         'type': 'int'
1844                                     },
1845                                     {
1846                                         'name': 'itemsrc_ranking',
1847                                         'type': 'int'
1848                                     },
1849                                     {
1850                                         'name': 'itemsrc_active',
1851                                         'type': 'int'
1852                                     },
1853                                     {
1854                                         'name': 'itemsrc_manuf_name',
1855                                         'type': 'string'
1856                                     },
1857                                     {
1858                                         'name': 'itemsrc_manuf_item_number',
1859                                         'type': 'string'
1860                                     },
1861                                     {
1862                                         'name': 'itemsrc_manuf_item_descrip',
1863                                         'type': 'string'
1864                                     },
1865                                     {
1866                                         'name': 'itemsrc_default',
1867                                         'type': 'int'
1868                                     },
1869                                     {
1870                                         'name': 'itemsrc_upccode',
1871                                         'type': 'string'
1872                                     }
1873                                 ],
1874                                 totalProperty : 'total'
1875                             },
1876                             '|xns' : 'Roo.data',
1877                             xtype : 'Store',
1878                             remoteSort : true,
1879                             sortInfo : { field : 'itemsrc_vend_id_vend_name', direction: 'ASC' },
1880                             xns : Roo.data,
1881                             listeners : {
1882                                 update : function (_self, record, operation)
1883                                    {
1884                                        Roo.log(operation);
1885                                          Roo.log(record);
1886                                       
1887                                        if (operation != 'commit') {
1888                                            return;
1889                                        }
1890                                        if (record.data.itemsrc_vend_id * 1 < 1) {
1891                                            return; // do not save.
1892                                        }
1893                                        if (record.data.itemsrc_id * 1 < 0) {
1894                                            return; // do not save. -- updating at present...
1895                                        }
1896                                        
1897                                        var p = Roo.apply({}, record.data);
1898                                        record.set('itemsrc_id', -1);    
1899                                        
1900                                        new Pman.Request({
1901                                            url : baseURL + '/Roo/Itemsrc',
1902                                            params : p,
1903                                            method : 'POST',
1904                                            success: function(res) {
1905                                                if (record.data.itemsrc_id *1  < 1) { 
1906                                                    record.set('itemsrc_id', res.data.itemsrc_id);
1907                                                }
1908                                            }
1909                                        });
1910                                        
1911                                        
1912                                    },
1913                                 beforeload : function (_self, o)
1914                                    {
1915                                        
1916                                        var id = 1 * _this.form.findField('item_id').getValue();
1917                                        if (!id) {
1918                                            this.removeAll();
1919                                            return false;
1920                                        }
1921                                        o.params.itemsrc_item_id = id;
1922                                    }
1923                             },
1924                             items : [
1925
1926                             ]
1927
1928                         },
1929                         footer : {
1930                             '|xns' : 'Roo',
1931                             pageSize : 25,
1932                             xtype : 'PagingToolbar',
1933                             emptyMsg : "No itemsrc found",
1934                             xns : Roo,
1935                             displayInfo : true,
1936                             displayMsg : "Displaying itemsrc{0} - {1} of {2}"
1937                         },
1938                         toolbar : {
1939                             '|xns' : 'Roo',
1940                             xtype : 'Toolbar',
1941                             xns : Roo,
1942                             items : [
1943                                 {
1944                                     '|xns' : 'Roo.Toolbar',
1945                                     text : "Add",
1946                                     xtype : 'Button',
1947                                     cls : 'x-btn-text-icon',
1948                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1949                                     xns : Roo.Toolbar,
1950                                     listeners : {
1951                                         click : function()
1952                                            {
1953                                                 
1954                                                Roo.log("add presed");
1955                                                 
1956                                                // work out last 
1957                                                var grid = _this.itemsrcgrid;
1958                                                 
1959                                                // uses form defaults or last row value.
1960                                                var nr = grid.ds.reader.newRow({
1961                                                         itemsrc_id : 0,
1962                                                    itemsrc_item_id : _this.form.findField('item_id').getValue(),
1963                                            
1964                                                     itemsrc_vend_id : 0,
1965                                                     itemsrc_vend_item_number : '',
1966                                                     itemsrc_vend_item_descrip : '',
1967                                                     itemsrc_comments           : '',
1968                                                     itemsrc_vend_uom  :           'EA',
1969                                                     itemsrc_invvendoruomratio : 1.0,
1970                                                     itemsrc_minordqty        : 0,
1971                                                     itemsrc_multordqty        : 0,
1972                                                     itemsrc_leadtime         :  30,
1973                                                     itemsrc_ranking         :   0,
1974                                                     itemsrc_active          :   true,
1975                                                     itemsrc_manuf_name       :  '',
1976                                                     itemsrc_manuf_item_number : '',
1977                                                     itemsrc_manuf_item_descrip: '',
1978                                                     itemsrc_default          : true,
1979                                                     itemsrc_upccode    : ''
1980                                                                    
1981                                                });
1982                                                grid.stopEditing();
1983                                                grid.ds.insert(0, nr); 
1984                                                grid.startEditing(0, 0); // type..
1985                                            
1986                                            }
1987                                     }
1988                                 }
1989                             ]
1990
1991                         },
1992                         '|xns' : 'Roo.grid',
1993                         autoExpandColumn : 'itemsrc_comments',
1994                         xtype : 'EditorGrid',
1995                         loadMask : true,
1996                         clicksToEdit : 1,
1997                         xns : Roo.grid,
1998                         colModel : [
1999                                  {
2000                                         editor : {
2001                                             field : {
2002                                                 store : {
2003                                                     proxy : {
2004                                                         '|xns' : 'Roo.data',
2005                                                         url : baseURL + '/Roo/vendinfo.php',
2006                                                         xtype : 'HttpProxy',
2007                                                         method : 'GET',
2008                                                         xns : Roo.data
2009                                                     },
2010                                                     reader : {
2011                                                         '|xns' : 'Roo.data',
2012                                                         id : 'id',
2013                                                         root : 'data',
2014                                                         xtype : 'JsonReader',
2015                                                         xns : Roo.data,
2016                                                         fields : [{"name":"id","type":"int"},{"name":"vend_name","type":"string"}],
2017                                                         totalProperty : 'total'
2018                                                     },
2019                                                     '|xns' : 'Roo.data',
2020                                                     xtype : 'Store',
2021                                                     remoteSort : true,
2022                                                     xns : Roo.data,
2023                                                     sortInfo : { direction : 'ASC', field: 'id' },
2024                                                     listeners : {
2025                                                         beforeload : function (_self, o){
2026                                                                o.params = o.params || {};
2027                                                                // set more here
2028                                                            }
2029                                                     },
2030                                                     items : [
2031
2032                                                     ]
2033
2034                                                 },
2035                                                 '|xns' : 'Roo.form',
2036                                                 listWidth : 400,
2037                                                 triggerAction : 'all',
2038                                                 forceSelection : true,
2039                                                 selectOnFocus : true,
2040                                                 pageSize : 20,
2041                                                 displayField : 'vend_name',
2042                                                 emptyText : "Select Vendor",
2043                                                 hiddenName : 'itemsrc_vend_id',
2044                                                 minChars : 2,
2045                                                 valueField : 'vend_id',
2046                                                 xtype : 'ComboBox',
2047                                                 allowBlank : false,
2048                                                 typeAhead : true,
2049                                                 editable : true,
2050                                                 width : 300,
2051                                                 xns : Roo.form,
2052                                                 name : 'itemsrc_vend_id_vend_name',
2053                                                 qtip : "Select vendinfo",
2054                                                 queryParam : 'q[search]',
2055                                                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{vend_name}</b> </div>',
2056                                                 loadingText : "Searching...",
2057                                                 items : [
2058
2059                                                 ]
2060
2061                                             },
2062                                             '|xns' : 'Roo.grid',
2063                                             xtype : 'GridEditor',
2064                                             xns : Roo.grid,
2065                                             items : [
2066
2067                                             ]
2068
2069                                         },
2070                                         '|xns' : 'Roo.grid',
2071                                         xtype : 'ColumnModel',
2072                                         width : 120,
2073                                         header : 'Vendor',
2074                                         renderer : function(v,x,r) { return String.format('{0}', r.data.itemsrc_vend_id_vend_name); },
2075                                         xns : Roo.grid,
2076                                         dataIndex : 'itemsrc_vend_id',
2077                                         items : [
2078
2079                                         ]
2080
2081                                     },
2082 {
2083                                         editor : {
2084                                             field : {
2085                                                 '|xns' : 'Roo.form',
2086                                                 xtype : 'TextField',
2087                                                 xns : Roo.form
2088                                             },
2089                                             '|xns' : 'Roo.grid',
2090                                             xtype : 'GridEditor',
2091                                             xns : Roo.grid,
2092                                             items : [
2093
2094                                             ]
2095
2096                                         },
2097                                         '|xns' : 'Roo.grid',
2098                                         xtype : 'ColumnModel',
2099                                         width : 100,
2100                                         header : 'Vendor Ref#',
2101                                         renderer : function(v) { return String.format('{0}', v); },
2102                                         xns : Roo.grid,
2103                                         dataIndex : 'itemsrc_vend_item_number',
2104                                         items : [
2105
2106                                         ]
2107
2108                                     },
2109 {
2110                                         editor : {
2111                                             field : {
2112                                                 '|xns' : 'Roo.form',
2113                                                 xtype : 'TextField',
2114                                                 xns : Roo.form
2115                                             },
2116                                             '|xns' : 'Roo.grid',
2117                                             xtype : 'GridEditor',
2118                                             xns : Roo.grid,
2119                                             items : [
2120
2121                                             ]
2122
2123                                         },
2124                                         '|xns' : 'Roo.grid',
2125                                         xtype : 'ColumnModel',
2126                                         width : 200,
2127                                         header : 'Comments',
2128                                         renderer : function(v) { return String.format('{0}', v); },
2129                                         xns : Roo.grid,
2130                                         dataIndex : 'itemsrc_comments',
2131                                         items : [
2132
2133                                         ]
2134
2135                                     },
2136 {
2137                                         '|xns' : 'Roo.grid',
2138                                         xtype : 'ColumnModel',
2139                                         width : 50,
2140                                         header : 'UOM',
2141                                         renderer : function(v) { return String.format('{0}', v); },
2142                                         xns : Roo.grid,
2143                                         dataIndex : 'itemsrc_vend_uom'
2144                                     },
2145 {
2146                                         editor : {
2147                                             field : {
2148                                                 '|xns' : 'Roo.form',
2149                                                 minValue : 0,
2150                                                 xtype : 'NumberField',
2151                                                 decimalPrecision : 0,
2152                                                 xns : Roo.form
2153                                             },
2154                                             '|xns' : 'Roo.grid',
2155                                             xtype : 'GridEditor',
2156                                             xns : Roo.grid,
2157                                             items : [
2158
2159                                             ]
2160
2161                                         },
2162                                         '|xns' : 'Roo.grid',
2163                                         align : 'right',
2164                                         xtype : 'ColumnModel',
2165                                         header : 'Min Qty',
2166                                         width : 50,
2167                                         renderer : function(v) { return String.format('{0}', v); },
2168                                         xns : Roo.grid,
2169                                         dataIndex : 'itemsrc_minordqty',
2170                                         items : [
2171
2172                                         ]
2173
2174                                     },
2175 {
2176                                         editor : {
2177                                             field : {
2178                                                 '|xns' : 'Roo.form',
2179                                                 minValue : 0,
2180                                                 xtype : 'NumberField',
2181                                                 decimalPrecision : 0,
2182                                                 xns : Roo.form
2183                                             },
2184                                             '|xns' : 'Roo.grid',
2185                                             xtype : 'GridEditor',
2186                                             xns : Roo.grid,
2187                                             items : [
2188
2189                                             ]
2190
2191                                         },
2192                                         '|xns' : 'Roo.grid',
2193                                         align : 'right',
2194                                         xtype : 'ColumnModel',
2195                                         header : 'Lead time',
2196                                         width : 75,
2197                                         renderer : function(v) { return String.format('{0}', v); },
2198                                         xns : Roo.grid,
2199                                         dataIndex : 'itemsrc_leadtime',
2200                                         items : [
2201
2202                                         ]
2203
2204                                     },
2205 {
2206                                         '|xns' : 'Roo.grid',
2207                                         xtype : 'ColumnModel',
2208                                         width : 50,
2209                                         header : 'Active',
2210                                         renderer : function(v) { return String.format('{0}', v); },
2211                                         xns : Roo.grid,
2212                                         dataIndex : 'itemsrc_active'
2213                                     }
2214                         ],
2215                         listeners : {
2216                                 rowdblclick : function (_self, rowIndex, e)
2217                                    {
2218                                        if (!_this.dialog) return;
2219                                        _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
2220                                            _this.grid.footer.onClick('first');
2221                                        }); 
2222                                    },
2223                                 render : function() 
2224                                    {
2225                                        _this.itemsrcgrid = this; 
2226                                        //_this.dialog = Pman.Dialog.FILL_IN
2227                                        
2228                                    },
2229                                 afteredit : function (e)
2230                                    {
2231                                        e.record.commit();
2232                                    }
2233                         },
2234                         items : [
2235
2236                         ]
2237
2238                     },
2239                     '|xns' : 'Roo',
2240                     region : 'center',
2241                     fitToframe : true,
2242                     background : true,
2243                     title : "Suppliers",
2244                     xtype : 'GridPanel',
2245                     fitContainer : true,
2246                     xns : Roo,
2247                     tableName : 'itemsrc',
2248                     listeners : {
2249                         activate : function() {
2250                                _this.itemsrcpanel = this;
2251                                if (_this.itemsrcgrid) {
2252                                    _this.itemsrcgrid.footer.onClick('first');
2253                                }
2254                            }
2255                     },
2256                     items : [
2257
2258                     ]
2259
2260                 },
2261                 {
2262                     grid : {
2263                         dataSource : {
2264                             proxy : {
2265                                 '|xns' : 'Roo.data',
2266                                 url : baseURL + '/Roo/events.php',
2267                                 method : 'GET',
2268                                 xtype : 'HttpProxy',
2269                                 xns : Roo.data
2270                             },
2271                             reader : {
2272                                 '|xns' : 'Roo.data',
2273                                 id : 'id',
2274                                 root : 'data',
2275                                 xtype : 'JsonReader',
2276                                 fields : [
2277                                     {
2278                                         'name': 'event_when',
2279                                         'type': 'date'
2280                                     },
2281                                     {
2282                                         'name': 'action',
2283                                         'type': 'string'
2284                                     },
2285                                     {
2286                                         'name': 'ipaddr',
2287                                         'type': 'string'
2288                                     },
2289                                     {
2290                                         'name': 'person_id_name',
2291                                         'type': 'string'
2292                                     },
2293                                     {
2294                                         'name': 'remarks',
2295                                         'type': 'string'
2296                                     }
2297                                 ],
2298                                 xns : Roo.data,
2299                                 totalProperty : 'total'
2300                             },
2301                             '|xns' : 'Roo.data',
2302                             xtype : 'Store',
2303                             remoteSort : true,
2304                             sortInfo : { field : 'event_when', direction: 'DESC' },
2305                             xns : Roo.data,
2306                             listeners : {
2307                                 beforeload : function (_self, options)
2308                                    {
2309                                        options.params = options.params || {};
2310                                        
2311                                        options.params.on_table = 'item';
2312                                        options.params.on_id = _this.form.findField('item_id').getValue();
2313                                    }
2314                             },
2315                             items : [
2316
2317                             ]
2318
2319                         },
2320                         footer : {
2321                             '|xns' : 'Roo',
2322                             pageSize : 25,
2323                             xtype : 'PagingToolbar',
2324                             emptyMsg : "No Events found",
2325                             xns : Roo,
2326                             displayMsg : "Displaying events{0} - {1} of {2}",
2327                             displayInfo : true
2328                         },
2329                         '|xns' : 'Roo.grid',
2330                         autoExpandColumn : 'remarks',
2331                         xtype : 'Grid',
2332                         loadMask : true,
2333                         xns : Roo.grid,
2334                         colModel : [
2335                                  {
2336                                         '|xns' : 'Roo.grid',
2337                                         xtype : 'ColumnModel',
2338                                         width : 120,
2339                                         header : 'Changed',
2340                                         renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y H:i:s') : ''); },
2341                                         xns : Roo.grid,
2342                                         dataIndex : 'event_when'
2343                                     },
2344 {
2345                                         '|xns' : 'Roo.grid',
2346                                         xtype : 'ColumnModel',
2347                                         width : 200,
2348                                         header : 'Action',
2349                                         renderer : function(v,x,r) { return String.format('{0} - {1}', v, r.data.on_table); },
2350                                         xns : Roo.grid,
2351                                         dataIndex : 'action'
2352                                     },
2353 {
2354                                         '|xns' : 'Roo.grid',
2355                                         xtype : 'ColumnModel',
2356                                         width : 200,
2357                                         header : 'IP Address',
2358                                         renderer : function(v) { return String.format('{0}', v); },
2359                                         xns : Roo.grid,
2360                                         dataIndex : 'ipaddr'
2361                                     },
2362 {
2363                                         '|xns' : 'Roo.grid',
2364                                         xtype : 'ColumnModel',
2365                                         width : 75,
2366                                         header : 'Who',
2367                                         renderer : function(v) { return String.format('{0}', v); },
2368                                         xns : Roo.grid,
2369                                         dataIndex : 'person_id_name'
2370                                     },
2371 {
2372                                         '|xns' : 'Roo.grid',
2373                                         xtype : 'ColumnModel',
2374                                         width : 200,
2375                                         header : 'Notes',
2376                                         renderer : function(v) { return String.format('{0}', v); },
2377                                         xns : Roo.grid,
2378                                         dataIndex : 'remarks'
2379                                     }
2380                         ],
2381                         listeners : {
2382                                 render : function() 
2383                                    {
2384                                        _this.hgrid = this; 
2385                                        if (_this.hpanel.active) {
2386                                           this.footer.onClick('first');
2387                                        }
2388                                    }
2389                         },
2390                         items : [
2391
2392                         ]
2393
2394                     },
2395                     '|xns' : 'Roo',
2396                     region : 'center',
2397                     fitToframe : true,
2398                     background : true,
2399                     title : "History",
2400                     xtype : 'GridPanel',
2401                     fitContainer : true,
2402                     xns : Roo,
2403                     tableName : 'events',
2404                     listeners : {
2405                         activate : function() {
2406                                _this.hpanel = this;
2407                                if (_this.hgrid) {
2408                                    _this.hgrid.footer.onClick('first');
2409                                }
2410                            }
2411                     },
2412                     items : [
2413
2414                     ]
2415
2416                 }
2417             ]
2418
2419         });
2420     }
2421 };