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