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