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