Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleVendorEdit.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.XtupleVendorEdit = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             listeners : {
34                 show : function (_self)
35                 {
36                     this.layout.getRegion('center').showPanel(0);
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 550,
42             modal : true,
43             resizable : false,
44             title : "Edit / Create Vendor",
45             width : 600,
46             items : [
47                 {
48                     xtype: 'ContentPanel',
49                     xns: Roo,
50                     region : 'center',
51                     title : "Details",
52                     items : [
53                         {
54                             xtype: 'Form',
55                             xns: Roo.form,
56                             listeners : {
57                                 actioncomplete : function(_self,action)
58                                 {
59                                     if (action.type == 'setdata') {
60                                         if(_this.data.vend_id){
61                                             _this.dialog.el.mask("Loading");
62                                             this.load({ method: 'GET', params: { '_id' : _this.data.vend_id }});     
63                                         }
64                                        
65                                        return;
66                                     }
67                                     if (action.type == 'load') {
68                                         _this.data = action.result.data;
69                                         _this.form.findField('addr_view').sync();
70                                         _this.dialog.el.unmask();
71                                         return;
72                                     }
73                                     if (action.type =='submit') {
74                                     
75                                         _this.dialog.el.unmask();
76                                         _this.dialog.hide();
77                                     
78                                          if (_this.callback) {
79                                             _this.callback.call(_this, _this.form.getValues());
80                                          }
81                                          _this.form.reset();
82                                          return;
83                                     }
84                                 },
85                                 rendered : function (form)
86                                 {
87                                     _this.form= form;
88                                 }
89                             },
90                             method : 'POST',
91                             style : 'margin:10px;',
92                             url : baseURL + '/Roo/vendinfo.php',
93                             items : [
94                                 {
95                                     xtype: 'FieldSet',
96                                     xns: Roo.form,
97                                     legend : "Basic Details",
98                                     style : 'width:450px',
99                                     items : [
100                                         {
101                                             xtype: 'TextField',
102                                             xns: Roo.form,
103                                             listeners : {
104                                                 keyup : function (_self, e)
105                                                 {
106                                                     if (!(_this.form.findField('vend_id').getValue() * 1)) {
107                                                     
108                                                         _this.form.findField('vend_number').setValue(this.getValue().replace(/[^a-z0-9]/ig, '').toUpperCase());
109                                                     
110                                                     }
111                                                 }
112                                             },
113                                             allowBlank : false,
114                                             fieldLabel : 'Name',
115                                             name : 'vend_name',
116                                             width : 200
117                                         },
118                                         {
119                                             xtype: 'TextField',
120                                             xns: Roo.form,
121                                             allowBlank : false,
122                                             fieldLabel : 'Vendor #',
123                                             name : 'vend_number',
124                                             readOnly : true,
125                                             width : 200
126                                         },
127                                         {
128                                             xtype: 'TextField',
129                                             xns: Roo.form,
130                                             allowBlank : true,
131                                             fieldLabel : 'Ship Via',
132                                             name : 'vend_shipvia',
133                                             width : 200
134                                         },
135                                         {
136                                             xtype: 'ComboBox',
137                                             xns: Roo.form,
138                                             allowBlank : false,
139                                             alwaysQuery : true,
140                                             displayField : 'curr_symbol',
141                                             editable : false,
142                                             emptyText : "Select Currency",
143                                             fieldLabel : 'Currency',
144                                             forceSelection : true,
145                                             hiddenName : 'vend_curr_id',
146                                             listWidth : 400,
147                                             loadingText : "Searching...",
148                                             minChars : 2,
149                                             name : 'vend_curr_id_curr_symbol',
150                                             pageSize : 20,
151                                             qtip : "Select Currency",
152                                             queryParam : 'query[curr_symbol]',
153                                             selectOnFocus : true,
154                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_symbol}</b> </div>',
155                                             triggerAction : 'all',
156                                             typeAhead : true,
157                                             valueField : 'curr_id',
158                                             width : 200,
159                                             store : {
160                                                 xtype: 'Store',
161                                                 xns: Roo.data,
162                                                 listeners : {
163                                                     beforeload : function (_self, o){
164                                                         o.params = o.params || {};
165                                                     }
166                                                 },
167                                                 remoteSort : true,
168                                                 sortInfo : { direction : 'ASC', field: 'curr_symbol' },
169                                                 proxy : {
170                                                     xtype: 'HttpProxy',
171                                                     xns: Roo.data,
172                                                     method : 'GET',
173                                                     url : baseURL + '/Roo/curr_symbol.php'
174                                                 },
175                                                 reader : {
176                                                     xtype: 'JsonReader',
177                                                     xns: Roo.data,
178                                                     id : 'curr_id',
179                                                     root : 'data',
180                                                     totalProperty : 'total',
181                                                     fields : [{"name":"curr_id","type":"int"},"curr_symbol"]
182                                                 }
183                                             }
184                                         },
185                                         {
186                                             xtype: 'ComboBox',
187                                             xns: Roo.form,
188                                             allowBlank : false,
189                                             alwaysQuery : true,
190                                             displayField : 'terms_descrip',
191                                             editable : false,
192                                             emptyText : "Select Terms",
193                                             fieldLabel : 'Terms',
194                                             forceSelection : true,
195                                             hiddenName : 'vend_terms_id',
196                                             listWidth : 400,
197                                             loadingText : "Searching...",
198                                             minChars : 2,
199                                             name : 'vend_terms_id_terms_descrip',
200                                             pageSize : 20,
201                                             qtip : "Select Terms",
202                                             queryParam : 'query[terms_descrip]',
203                                             selectOnFocus : true,
204                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
205                                             triggerAction : 'all',
206                                             typeAhead : true,
207                                             valueField : 'terms_id',
208                                             width : 200,
209                                             store : {
210                                                 xtype: 'Store',
211                                                 xns: Roo.data,
212                                                 listeners : {
213                                                     beforeload : function (_self, o){
214                                                         o.params = o.params || {};
215                                                     }
216                                                 },
217                                                 remoteSort : true,
218                                                 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
219                                                 proxy : {
220                                                     xtype: 'HttpProxy',
221                                                     xns: Roo.data,
222                                                     method : 'GET',
223                                                     url : baseURL + '/Roo/terms.php'
224                                                 },
225                                                 reader : {
226                                                     xtype: 'JsonReader',
227                                                     xns: Roo.data,
228                                                     id : 'terms_id',
229                                                     root : 'data',
230                                                     totalProperty : 'total',
231                                                     fields : [{"name":"terms_id","type":"int"},"terms_descrip"]
232                                                 }
233                                             }
234                                         },
235                                         {
236                                             xtype: 'ComboBox',
237                                             xns: Roo.form,
238                                             allowBlank : false,
239                                             alwaysQuery : true,
240                                             displayField : 'taxzone_descrip',
241                                             editable : false,
242                                             emptyText : "Select Taxzone",
243                                             fieldLabel : 'Tax Zone',
244                                             forceSelection : true,
245                                             hiddenName : 'vend_taxzone_id',
246                                             listWidth : 400,
247                                             loadingText : "Searching...",
248                                             minChars : 2,
249                                             name : 'vend_taxzone_id_taxzone_descrip',
250                                             pageSize : 20,
251                                             qtip : "Select Taxzone",
252                                             queryParam : 'query[taxzone_descrip]',
253                                             selectOnFocus : true,
254                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
255                                             triggerAction : 'all',
256                                             typeAhead : true,
257                                             valueField : 'taxzone_id',
258                                             width : 200,
259                                             store : {
260                                                 xtype: 'Store',
261                                                 xns: Roo.data,
262                                                 listeners : {
263                                                     beforeload : function (_self, o){
264                                                         o.params = o.params || {};
265                                                     }
266                                                 },
267                                                 remoteSort : true,
268                                                 sortInfo : { direction : 'ASC', field: 'taxzone_descrip' },
269                                                 proxy : {
270                                                     xtype: 'HttpProxy',
271                                                     xns: Roo.data,
272                                                     method : 'GET',
273                                                     url : baseURL + '/Roo/taxzone.php'
274                                                 },
275                                                 reader : {
276                                                     xtype: 'JsonReader',
277                                                     xns: Roo.data,
278                                                     id : 'taxzone_id',
279                                                     root : 'data',
280                                                     totalProperty : 'total',
281                                                     fields : [{"name":"taxzone_id","type":"int"},"taxzone_descrip"]
282                                                 }
283                                             }
284                                         },
285                                         {
286                                             xtype: 'ComboBox',
287                                             xns: Roo.form,
288                                             listeners : {
289                                                 add : function (combo)
290                                                 {
291                                                     Pman.Dialog.XtupleVendTypeEdit.show({vendtype_id : 0}, function(res){
292                                                         _this.form.findField('vend_vendtype_id').setFromData(res);
293                                                     
294                                                     });
295                                                 },
296                                                 edit : function (combo, record)
297                                                 {
298                                                     var s = _this.form.findField('vend_vendtype_id').getValue() * 1;
299                                                     if(s < 1){
300                                                         Roo.MessageBox.alert('Error','Please select a type');
301                                                         return;
302                                                     }
303                                                 
304                                                     Pman.Dialog.XtupleVendTypeEdit.show({vendtype_id : s}, function(res){
305                                                 
306                                                         _this.form.findField('vend_vendtype_id').setFromData(res);
307                                                     
308                                                     });
309                                                 }
310                                             },
311                                             allowBlank : false,
312                                             alwaysQuery : true,
313                                             displayField : 'vendtype_descrip',
314                                             editable : false,
315                                             emptyText : "Select Vendor Type",
316                                             fieldLabel : 'Type',
317                                             forceSelection : true,
318                                             hiddenName : 'vend_vendtype_id',
319                                             listWidth : 400,
320                                             loadingText : "Searching...",
321                                             minChars : 2,
322                                             name : 'vend_vendtype_id_vendtype_descrip',
323                                             pageSize : 20,
324                                             qtip : "Select Vendor Type",
325                                             queryParam : 'query[vendtype_descrip]',
326                                             selectOnFocus : true,
327                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{vendtype_descrip}</b> </div>',
328                                             triggerAction : 'all',
329                                             typeAhead : true,
330                                             valueField : 'vendtype_id',
331                                             width : 200,
332                                             store : {
333                                                 xtype: 'Store',
334                                                 xns: Roo.data,
335                                                 listeners : {
336                                                     beforeload : function (_self, o){
337                                                         o.params = o.params || {};
338                                                     }
339                                                 },
340                                                 remoteSort : true,
341                                                 sortInfo : { direction : 'ASC', field: 'vendtype_descrip' },
342                                                 proxy : {
343                                                     xtype: 'HttpProxy',
344                                                     xns: Roo.data,
345                                                     method : 'GET',
346                                                     url : baseURL + '/Roo/vendtype.php'
347                                                 },
348                                                 reader : {
349                                                     xtype: 'JsonReader',
350                                                     xns: Roo.data,
351                                                     id : 'vendtype_id',
352                                                     root : 'data',
353                                                     totalProperty : 'total',
354                                                     fields : [{"name":"vendtype_id","type":"int"},"vendtype_descrip"]
355                                                 }
356                                             }
357                                         },
358                                         {
359                                             xtype: 'Checkbox',
360                                             xns: Roo.form,
361                                             fieldLabel : 'Active',
362                                             inputValue : 'true',
363                                             name : 'vend_active',
364                                             valueOff : 0
365                                         },
366                                         {
367                                             xtype: 'TextArea',
368                                             xns: Roo.form,
369                                             allowBlank : true,
370                                             fieldLabel : 'Comments',
371                                             name : 'vend_comments'
372                                         }
373                                     ]
374                                 },
375                                 {
376                                     xtype: 'FieldSet',
377                                     xns: Roo.form,
378                                     hideLabels : true,
379                                     legend : "Address",
380                                     style : 'width:450px;',
381                                     items : [
382                                         {
383                                             xtype: 'ComboBox',
384                                             xns: Roo.form,
385                                             listeners : {
386                                                 add : function (combo)
387                                                 {
388                                                     Pman.Dialog.XtupleAddress.show({addr_id : 0});
389                                                 },
390                                                 edit : function (combo, record)
391                                                 {
392                                                     var s = _this.form.findField('vend_addr_id').getValue() * 1;
393                                                     if(s < 1){
394                                                         Roo.MessageBox.alert('Error','Please select a address');
395                                                         return;
396                                                     }
397                                                     Pman.Dialog.XtupleAddress.show({addr_id : s});
398                                                 },
399                                                 select : function (combo, record, index)
400                                                 {
401                                                     for(var i in record.data) {
402                                                         _this.data['vend_addr_id_' + i] = record.data[i];
403                                                     }
404                                                 
405                                                     _this.form.findField('addr_view').sync();
406                                                 }
407                                             },
408                                             allowBlank : false,
409                                             alwaysQuery : true,
410                                             displayField : 'addr_number',
411                                             editable : true,
412                                             emptyText : "Select Address",
413                                             fieldLabel : 'Address',
414                                             forceSelection : true,
415                                             hiddenName : 'vend_addr_id',
416                                             listWidth : 400,
417                                             loadingText : "Searching...",
418                                             minChars : 2,
419                                             name : 'vend_addr_id_addr_number',
420                                             pageSize : 20,
421                                             qtip : "Select Address",
422                                             queryParam : 'query[address]',
423                                             selectOnFocus : true,
424                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>#{addr_id} - {addr_number}</b> </div>',
425                                             triggerAction : 'all',
426                                             typeAhead : true,
427                                             valueField : 'addr_id',
428                                             width : 400,
429                                             store : {
430                                                 xtype: 'Store',
431                                                 xns: Roo.data,
432                                                 listeners : {
433                                                     beforeload : function (_self, o){
434                                                         o.params = o.params || {};
435                                                         addr_active = 1;
436                                                     }
437                                                 },
438                                                 remoteSort : true,
439                                                 sortInfo : { direction : 'DESC', field: 'addr_id' },
440                                                 proxy : {
441                                                     xtype: 'HttpProxy',
442                                                     xns: Roo.data,
443                                                     method : 'GET',
444                                                     url : baseURL + '/Roo/addr.php'
445                                                 },
446                                                 reader : {
447                                                     xtype: 'JsonReader',
448                                                     xns: Roo.data,
449                                                     id : 'addr_id',
450                                                     root : 'data',
451                                                     totalProperty : 'total',
452                                                     fields : [{"name":"addr_id","type":"int"},"addr_number"]
453                                                 }
454                                             }
455                                         },
456                                         {
457                                             xtype: 'TextArea',
458                                             xns: Roo.form,
459                                             allowBlank : true,
460                                             fieldLabel : 'Notes',
461                                             name : 'addr_view',
462                                             readOnly : true,
463                                             width : 400,
464                                             sync : function() {
465                                                 var a = [ 'line1', 'line2', 'line3', 'city', 'state', 'country' ];
466                                                 var v = [];
467                                                 
468                                                 Roo.each(a, function(e) {
469                                                     if (_this.data['vend_addr_id_addr_' +e].length) {
470                                                         v.push(_this.data['vend_addr_id_addr_' +e]);
471                                                     }
472                                                 });
473                                                 
474                                                 this.setValue(v.join("\n"));
475                                             }
476                                         }
477                                     ]
478                                 },
479                                 {
480                                     xtype: 'Hidden',
481                                     xns: Roo.form,
482                                     name : 'vend_id'
483                                 }
484                             ]
485                         }
486                     ]
487                 },
488                 {
489                     xtype: 'GridPanel',
490                     xns: Roo,
491                     listeners : {
492                         activate : function() {
493                             _this.panel = this;
494                             if (_this.grid) {
495                                 _this.grid.footer.onClick('first');
496                             }
497                         }
498                     },
499                     background : true,
500                     fitContainer : true,
501                     fitToframe : true,
502                     region : 'center',
503                     tableName : 'itemsrc',
504                     title : "Supplier of",
505                     grid : {
506                         xtype: 'Grid',
507                         xns: Roo.grid,
508                         listeners : {
509                             render : function() 
510                             {
511                                 _this.grid = this; 
512                                 //_this.dialog = Pman.Dialog.FILL_IN
513                                 if (_this.panel.active) {
514                                    this.footer.onClick('first');
515                                 }
516                             },
517                             rowdblclick : function (_self, rowIndex, e)
518                             {
519                                
520                                Pman.Dialog.XtupleItem.show({ item_id  : this.getDataSource().getAt(rowIndex).data.itemsrc_item_id }, function() {
521                                     _this.grid.footer.onClick('first');
522                                 }); 
523                             }
524                         },
525                         autoExpandColumn : 'itemsrc_vend_item_descrip',
526                         loadMask : true,
527                         dataSource : {
528                             xtype: 'Store',
529                             xns: Roo.data,
530                             listeners : {
531                                 beforeload : function (_self, options)
532                                 {
533                                     options.params.itemsrc_vend_id =   _this.form.findField('vend_id').getValue();
534                                     var s = _this.searchBox.getValue();
535                                     if (s.length) {
536                                         options.params['search[name]'] = s;
537                                     }
538                                 }
539                             },
540                             remoteSort : true,
541                             sortInfo : { field : 'itemsrc_item_id_item_number', direction: 'ASC' },
542                             proxy : {
543                                 xtype: 'HttpProxy',
544                                 xns: Roo.data,
545                                 method : 'GET',
546                                 url : baseURL + '/Roo/itemsrc.php'
547                             },
548                             reader : {
549                                 xtype: 'JsonReader',
550                                 xns: Roo.data,
551                                 totalProperty : 'total',
552                                 root : 'data',
553                                 id : 'id',
554                                 fields : [
555                                     {
556                                         'name': 'itemsrc_id',
557                                         'type': 'int'
558                                     },
559                                     {
560                                         'name': 'itemsrc_item_id',
561                                         'type': 'int'
562                                     },
563                                     {
564                                         'name': 'itemsrc_item_id',
565                                         'type': 'int'
566                                     },
567                                     {
568                                         'name': 'itemsrc_vend_id',
569                                         'type': 'int'
570                                     },
571                                     {
572                                         'name': 'itemsrc_vend_id',
573                                         'type': 'int'
574                                     },
575                                     {
576                                         'name': 'itemsrc_vend_item_number',
577                                         'type': 'string'
578                                     },
579                                     {
580                                         'name': 'itemsrc_vend_item_descrip',
581                                         'type': 'string'
582                                     },
583                                     {
584                                         'name': 'itemsrc_comments',
585                                         'type': 'string'
586                                     },
587                                     {
588                                         'name': 'itemsrc_vend_uom',
589                                         'type': 'string'
590                                     },
591                                     {
592                                         'name': 'itemsrc_invvendoruomratio',
593                                         'type': 'float'
594                                     },
595                                     {
596                                         'name': 'itemsrc_minordqty',
597                                         'type': 'float'
598                                     },
599                                     {
600                                         'name': 'itemsrc_multordqty',
601                                         'type': 'float'
602                                     },
603                                     {
604                                         'name': 'itemsrc_leadtime',
605                                         'type': 'int'
606                                     },
607                                     {
608                                         'name': 'itemsrc_ranking',
609                                         'type': 'int'
610                                     },
611                                     {
612                                         'name': 'itemsrc_active',
613                                         'type': 'int'
614                                     },
615                                     {
616                                         'name': 'itemsrc_manuf_name',
617                                         'type': 'string'
618                                     },
619                                     {
620                                         'name': 'itemsrc_manuf_item_number',
621                                         'type': 'string'
622                                     },
623                                     {
624                                         'name': 'itemsrc_manuf_item_descrip',
625                                         'type': 'string'
626                                     },
627                                     {
628                                         'name': 'itemsrc_default',
629                                         'type': 'int'
630                                     },
631                                     {
632                                         'name': 'itemsrc_upccode',
633                                         'type': 'string'
634                                     }
635                                 ]
636                             }
637                         },
638                         footer : {
639                             xtype: 'PagingToolbar',
640                             xns: Roo,
641                             displayInfo : true,
642                             displayMsg : "Displaying itemsrc{0} - {1} of {2}",
643                             emptyMsg : "No itemsrc found",
644                             pageSize : 100
645                         },
646                         toolbar : {
647                             xtype: 'Toolbar',
648                             xns: Roo,
649                             items : [
650                                 {
651                                     xtype: 'TextField',
652                                     xns: Roo.form,
653                                     listeners : {
654                                         render : function (_self)
655                                         {
656                                             _this.searchBox = _self;
657                                         },
658                                         specialkey : function (_self, e)
659                                         {
660                                             _this.grid.footer.onClick('first');
661                                         }
662                                     }
663                                 },
664                                 {
665                                     xtype: 'Button',
666                                     xns: Roo.Toolbar,
667                                     listeners : {
668                                         click : function (_self, e)
669                                         {
670                                         _this.grid.footer.onClick('first');
671                                         }
672                                     },
673                                     cls : 'x-btn-icon',
674                                     icon : rootURL + '/Pman/templates/images/search.gif'
675                                 },
676                                 {
677                                     xtype: 'Button',
678                                     xns: Roo.Toolbar,
679                                     listeners : {
680                                         click : function (_self, e)
681                                         {
682                                             _this.searchBox.setValue('');
683                                             
684                                             _this.grid.footer.onClick('first');
685                                         }
686                                     },
687                                     cls : 'x-btn-icon',
688                                     icon : rootURL + '/Pman/templates/images/edit-clear.gif'
689                                 },
690                                 {
691                                     xtype: 'Fill',
692                                     xns: Roo.Toolbar
693                                 },
694                                 {
695                                     xtype: 'Button',
696                                     xns: Roo.Toolbar,
697                                     listeners : {
698                                         click : function()
699                                         {
700                                            
701                                             Pman.Dialog.XtupleSalesProductList.show({
702                                                 exclude_itemsrc_vendor : _this.form.findField('vend_id').getValue(),
703                                                 multi_select : true
704                                             
705                                             }, function(sels) {
706                                                Roo.log(sels); 
707                                         
708                                                var ids = [];
709                                                Roo.each(sels,function(rec) {
710                                                     ids.push(rec.data.item_id);
711                                                 });
712                                                 new Pman.Request({
713                                                     mask: "Adding",
714                                                     url : baseURL + '/Roo/Itemsrc',
715                                                     method: 'POST',
716                                                     params : {
717                                                         add_multiple : ids.join(','),
718                                                         itemsrc_vend_id : _this.form.findField('vend_id').getValue()
719                                                     },
720                                                     success : function() { 
721                                                         
722                                                     
723                                                           _this.grid.footer.onClick('first');
724                                                   }
725                                               });
726                                                       
727                                             
728                                             });
729                                            
730                                         }
731                                     },
732                                     cls : 'x-btn-text-icon',
733                                     text : "Add",
734                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
735                                 },
736                                 {
737                                     xtype: 'Button',
738                                     xns: Roo.Toolbar,
739                                     listeners : {
740                                         click : function()
741                                         {
742                                              Pman.genericDelete(_this, 'itemsrc'); 
743                                         }
744                                     },
745                                     cls : 'x-btn-text-icon',
746                                     text : "Delete",
747                                     icon : rootURL + '/Pman/templates/images/trash.gif'
748                                 }
749                             ]
750                         },
751                         colModel : [
752                             {
753                                 xtype: 'ColumnModel',
754                                 xns: Roo.grid,
755                                 dataIndex : 'itemsrc_item_id_item_number',
756                                 header : 'Item',
757                                 width : 120,
758                                 renderer : function(v) { return String.format('{0}', v); }
759                             },
760                             {
761                                 xtype: 'ColumnModel',
762                                 xns: Roo.grid,
763                                 dataIndex : 'itemsrc_vend_item_number',
764                                 header : 'Vendor item number',
765                                 width : 120,
766                                 renderer : function(v) { return String.format('{0}', v); }
767                             },
768                             {
769                                 xtype: 'ColumnModel',
770                                 xns: Roo.grid,
771                                 dataIndex : 'itemsrc_vend_item_descrip',
772                                 header : 'Vendor item description',
773                                 width : 200,
774                                 renderer : function(v) { return String.format('{0}', v); }
775                             },
776                             {
777                                 xtype: 'ColumnModel',
778                                 xns: Roo.grid,
779                                 dataIndex : 'itemsrc_vend_uom',
780                                 header : 'Uom',
781                                 width : 50,
782                                 renderer : function(v) { return String.format('{0}', v); }
783                             },
784                             {
785                                 xtype: 'ColumnModel',
786                                 xns: Roo.grid,
787                                 dataIndex : 'itemsrc_minordqty',
788                                 header : 'Min ord qty',
789                                 width : 50,
790                                 renderer : function(v) { return String.format('{0}', v); }
791                             },
792                             {
793                                 xtype: 'ColumnModel',
794                                 xns: Roo.grid,
795                                 dataIndex : 'itemsrc_leadtime',
796                                 header : 'Lead time',
797                                 width : 75,
798                                 renderer : function(v) { return String.format('{0}', v); }
799                             },
800                             {
801                                 xtype: 'ColumnModel',
802                                 xns: Roo.grid,
803                                 dataIndex : 'itemsrc_active',
804                                 header : 'Active',
805                                 width : 75,
806                                 renderer : function(v) { return String.format('{0}', v); }
807                             }
808                         ]
809                     }
810                 },
811                 {
812                     xtype: 'GridPanel',
813                     xns: Roo,
814                     listeners : {
815                         activate : function() {
816                             _this.apanel = this;
817                             if (_this.agrid) {
818                                 _this.agrid.footer.onClick('first');
819                             }
820                         }
821                     },
822                     background : true,
823                     fitContainer : true,
824                     fitToframe : true,
825                     region : 'center',
826                     tableName : 'vendaddrinfo',
827                     title : "Addresses",
828                     grid : {
829                         xtype: 'Grid',
830                         xns: Roo.grid,
831                         listeners : {
832                             render : function() 
833                             {
834                                 _this.agrid = this; 
835                                 //_this.dialog = Pman.Dialog.FILL_IN
836                                 if (_this.apanel.active) {
837                                    this.footer.onClick('first');
838                                 }
839                             }
840                         },
841                         autoExpandColumn : 'vendaddr_addr_id_addr_line1',
842                         loadMask : true,
843                         sm : {
844                             xtype: 'RowSelectionModel',
845                             xns: Roo.grid,
846                             singleSelect : true
847                         },
848                         dataSource : {
849                             xtype: 'Store',
850                             xns: Roo.data,
851                             listeners : {
852                                 beforeload : function (_self, options)
853                                 {
854                                     options.params = options.params || {};
855                                     
856                                     var id = _this.form.findField('vend_id').getValue();
857                                     
858                                     if(id * 1 < 1){
859                                         return false;
860                                     }
861                                     
862                                     options.params.vendaddr_vend_id = id;
863                                 }
864                             },
865                             remoteSort : true,
866                             sortInfo : { field : 'vendaddr_id', direction: 'ASC' },
867                             proxy : {
868                                 xtype: 'HttpProxy',
869                                 xns: Roo.data,
870                                 method : 'GET',
871                                 url : baseURL + '/Roo/vendaddrinfo.php'
872                             },
873                             reader : {
874                                 xtype: 'JsonReader',
875                                 xns: Roo.data,
876                                 id : 'vendaddr_id',
877                                 root : 'data',
878                                 totalProperty : 'total',
879                                 fields : [
880                                     {
881                                         'name': 'vendaddr_id',
882                                         'type': 'int'
883                                     },
884                                     {
885                                         'name': 'vendaddr_vend_id',
886                                         'type': 'int'
887                                     },
888                                     {
889                                         'name': 'vendaddr_code',
890                                         'type': 'string'
891                                     }
892                                 ]
893                             }
894                         },
895                         footer : {
896                             xtype: 'PagingToolbar',
897                             xns: Roo,
898                             displayInfo : true,
899                             displayMsg : "Displaying address{0} - {1} of {2}",
900                             emptyMsg : "Nothing found",
901                             pageSize : 100
902                         },
903                         toolbar : {
904                             xtype: 'Toolbar',
905                             xns: Roo,
906                             items : [
907                                 {
908                                     xtype: 'Fill',
909                                     xns: Roo.Toolbar
910                                 },
911                                 {
912                                     xtype: 'Button',
913                                     xns: Roo.Toolbar,
914                                     listeners : {
915                                         click : function (_self, e)
916                                         {
917                                             var id = _this.form.findField('vend_id').getValue();
918                                             
919                                             if(id * 1 < 1){
920                                                 Roo.MessageBox.alert('Error', 'Please save the vendor first');
921                                                 return;
922                                             }
923                                             
924                                             Pman.Dialog.Image.show(
925                                                {
926                                                     _url : baseURL+'/Xtuple/Import/VendAddrInfo?' + Roo.urlEncode({'vend_id' : id})
927                                                 
928                                                },
929                                                function (data) {
930                                                     _this.agrid.footer.onClick('first');
931                                                }
932                                            );
933                                         }
934                                     },
935                                     text : "Upload"
936                                 },
937                                 {
938                                     xtype: 'Button',
939                                     xns: Roo.Toolbar,
940                                     listeners : {
941                                         click : function()
942                                         {
943                                              var s = _this.agrid.getSelectionModel().getSelected();
944                                              
945                                              if(!s || s.data.vendaddr_id * 1 < 1){
946                                                 Roo.MessageBox.alert('Error', 'Please select a row');
947                                                 return;
948                                              }
949                                              
950                                              Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
951                                                 function(v) {
952                                                     if (v != 'yes') {
953                                                         return;
954                                                     }
955                                                      new Pman.Request({
956                                                         method: 'POST',
957                                                         url: baseURL+ '/Roo/vendaddrinfo',
958                                                         params : {
959                                                             _delete : s.data.vendaddr_id
960                                                         },
961                                                         success : function() {
962                                                             _this.agrid.footer.onClick('refresh');
963                                                         }
964                                                     });
965                                             });
966                                         }
967                                     },
968                                     cls : 'x-btn-text-icon',
969                                     text : "Delete",
970                                     icon : rootURL + '/Pman/templates/images/trash.gif'
971                                 },
972                                 {
973                                     xtype: 'Button',
974                                     xns: Roo.Toolbar,
975                                     listeners : {
976                                         click : function()
977                                         {
978                                              var s = _this.form.findField('vend_id').getValue() * 1;
979                                              
980                                              if(!s || s * 1 < 1){
981                                                 Roo.MessageBox.alert('Error', 'Save first!');
982                                                 return;
983                                              }
984                                              
985                                              Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete all the address?",
986                                                 function(v) {
987                                                     if (v != 'yes') {
988                                                         return;
989                                                     }
990                                                      new Pman.Request({
991                                                         method: 'POST',
992                                                         url: baseURL+ '/Roo/vendinfo',
993                                                         params : {
994                                                             vend_id : s,
995                                                             _remove_addr : 1
996                                                         },
997                                                         success : function() {
998                                                             _this.agrid.footer.onClick('refresh');
999                                                         }
1000                                                     });
1001                                             });
1002                                         }
1003                                     },
1004                                     cls : 'x-btn-text-icon',
1005                                     text : "Delete All",
1006                                     icon : rootURL + '/Pman/templates/images/trash.gif'
1007                                 }
1008                             ]
1009                         },
1010                         colModel : [
1011                             {
1012                                 xtype: 'ColumnModel',
1013                                 xns: Roo.grid,
1014                                 dataIndex : 'vendaddr_code',
1015                                 header : 'Code',
1016                                 width : 75,
1017                                 renderer : function(v) { return String.format('{0}', v); }
1018                             },
1019                             {
1020                                 xtype: 'ColumnModel',
1021                                 xns: Roo.grid,
1022                                 dataIndex : 'vendaddr_addr_id_addr_city',
1023                                 header : 'District',
1024                                 width : 100,
1025                                 renderer : function(v) { return String.format('{0}', v); }
1026                             },
1027                             {
1028                                 xtype: 'ColumnModel',
1029                                 xns: Roo.grid,
1030                                 dataIndex : 'vendaddr_addr_id_addr_line1',
1031                                 header : 'Address Line 1',
1032                                 width : 200,
1033                                 renderer : function(v) { return String.format('{0}', v); }
1034                             },
1035                             {
1036                                 xtype: 'ColumnModel',
1037                                 xns: Roo.grid,
1038                                 dataIndex : 'vendaddr_addr_id_addr_line2',
1039                                 header : 'Address Line 2',
1040                                 width : 200,
1041                                 renderer : function(v) { return String.format('{0}', v); }
1042                             }
1043                         ]
1044                     }
1045                 }
1046             ],
1047             center : {
1048                 xtype: 'LayoutRegion',
1049                 xns: Roo,
1050                 tabPosition : 'top'
1051             },
1052             buttons : [
1053                 {
1054                     xtype: 'Button',
1055                     xns: Roo,
1056                     listeners : {
1057                         click : function (_self, e)
1058                         {
1059                             _this.dialog.hide();
1060                         }
1061                     },
1062                     text : "Cancel"
1063                 },
1064                 {
1065                     xtype: 'Button',
1066                     xns: Roo,
1067                     listeners : {
1068                         click : function (_self, e)
1069                         {
1070                             _this.form.doAction("submit");
1071                         
1072                         }
1073                     },
1074                     text : "Save"
1075                 }
1076             ]
1077         });
1078     }
1079 };