Pman.Tab.XtuplePurchasesVendors.bjs
[Pman.Xtuple] / Pman.Tab.XtuplePurchasesVendors.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.Tab.XtuplePurchasesVendors = new Roo.XComponent({
6     part     :  ["Xtuple","PurchasesVendors"],
7     order    : '300-Pman.Tab.XtuplePurchasesVendors',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtuplePurchases',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             background : true,
21             fitContainer : true,
22             fitToFrame : true,
23             region : 'center',
24             title : "Vendors",
25             layout : {
26                 xtype: 'BorderLayout',
27                 xns: Roo,
28                 items : [
29                     {
30                         xtype: 'GridPanel',
31                         xns: Roo,
32                         listeners : {
33                             activate : function() {
34                                 _this.panel = this;
35                                 if (_this.grid) {
36                                     _this.grid.footer.onClick('first');
37                                 }
38                             }
39                         },
40                         background : false,
41                         fitContainer : true,
42                         fitToframe : true,
43                         region : 'center',
44                         tableName : 'vendinfo',
45                         title : "Vendors",
46                         grid : {
47                             xtype: 'Grid',
48                             xns: Roo.grid,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     //_this.dialog = Pman.Dialog.FILL_IN
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 },
58                                 rowdblclick : function (_self, rowIndex, e)
59                                 {
60                                     var s = _this.grid.ds.getAt(rowIndex);
61                                     if(s.data.vend_id * 1 < 1){
62                                         Roo.MessageBox.alert("Error", "Select a row");
63                                     }
64                                     
65                                     Pman.Dialog.XtupleVendorEdit.show(s.data, function() {
66                                         _this.grid.footer.onClick('first');
67                                     }); 
68                                 }
69                             },
70                             autoExpandColumn : 'vend_name',
71                             loadMask : true,
72                             sm : {
73                                 xtype: 'RowSelectionModel',
74                                 xns: Roo.grid,
75                                 singleSelect : true
76                             },
77                             dataSource : {
78                                 xtype: 'Store',
79                                 xns: Roo.data,
80                                 listeners : {
81                                     beforeload : function (_self, options)
82                                     {
83                                         
84                                         if (! _this.searchBox) {
85                                         // not rendered yet...
86                                             return false;
87                                                 
88                                         }
89                                         options.params = options.params || {};
90                                         options.params._with_char = 1;
91                                         options.params['search[name]'] = _this.searchBox.getValue();
92                                         
93                                         if (!_this.active.pressed) {
94                                             options.params.vend_active = 1;
95                                         } 
96                                     }
97                                 },
98                                 remoteSort : true,
99                                 sortInfo : { field : 'vend_name', direction: 'ASC' },
100                                 proxy : {
101                                     xtype: 'HttpProxy',
102                                     xns: Roo.data,
103                                     method : 'GET',
104                                     url : baseURL + '/Roo/Vendinfo.php'
105                                 },
106                                 reader : {
107                                     xtype: 'JsonReader',
108                                     xns: Roo.data,
109                                     id : 'vend_id',
110                                     root : 'data',
111                                     totalProperty : 'total',
112                                     fields : [
113                                         {
114                                             'name': 'vend_id',
115                                             'type': 'int'
116                                         },
117                                         {
118                                             'name': 'vend_name',
119                                             'type': 'string'
120                                         }
121                                     ]
122                                 }
123                             },
124                             footer : {
125                                 xtype: 'PagingToolbar',
126                                 xns: Roo,
127                                 displayInfo : true,
128                                 displayMsg : "Displaying vendinfo{0} - {1} of {2}",
129                                 emptyMsg : "No vendinfo found",
130                                 pageSize : 25
131                             },
132                             toolbar : {
133                                 xtype: 'Toolbar',
134                                 xns: Roo,
135                                 items : [
136                                     {
137                                         xtype: 'TextItem',
138                                         xns: Roo.Toolbar,
139                                         text : "Search : "
140                                     },
141                                     {
142                                         xtype: 'TextField',
143                                         xns: Roo.form,
144                                         listeners : {
145                                             render : function (_self)
146                                             {
147                                                 _this.searchBox = _self;
148                                             },
149                                             specialkey : function (_self, e)
150                                             {
151                                                 _this.grid.footer.onClick('first');
152                                             }
153                                         }
154                                     },
155                                     {
156                                         xtype: 'Button',
157                                         xns: Roo.Toolbar,
158                                         listeners : {
159                                             click : function (_self, e)
160                                             {
161                                             _this.grid.footer.onClick('first');
162                                             }
163                                         },
164                                         cls : 'x-btn-icon',
165                                         icon : rootURL + '/Pman/templates/images/search.gif'
166                                     },
167                                     {
168                                         xtype: 'Button',
169                                         xns: Roo.Toolbar,
170                                         listeners : {
171                                             click : function (_self, e)
172                                             {
173                                                 _this.searchBox.setValue('');
174                                                 
175                                                 
176                                                 _this.grid.footer.onClick('first');
177                                             }
178                                         },
179                                         cls : 'x-btn-icon',
180                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif'
181                                     },
182                                     {
183                                         xtype: 'Separator',
184                                         xns: Roo.Toolbar
185                                     },
186                                     {
187                                         xtype: 'Button',
188                                         xns: Roo.Toolbar,
189                                         listeners : {
190                                             toggle : function (_self, pressed)
191                                             {
192                                             
193                                                 this.setText(pressed ? "Hide Inactive" : "Show Inactive");
194                                                 (function() { _this.grid.footer.onClick('first'); }).defer(100);
195                                             },
196                                             render : function (_self)
197                                             {
198                                                 _this.active = _self;
199                                             }
200                                         },
201                                         enableToggle : true,
202                                         text : "Show Inactive"
203                                     },
204                                     {
205                                         xtype: 'Fill',
206                                         xns: Roo.Toolbar
207                                     },
208                                     {
209                                         xtype: 'Button',
210                                         xns: Roo.Toolbar,
211                                         listeners : {
212                                             click : function()
213                                             {
214                                             
215                                                Pman.Dialog.XtupleVendorEdit.show( { id : 0 } , function() {
216                                                     _this.grid.footer.onClick('first');
217                                                }); 
218                                             }
219                                         },
220                                         cls : 'x-btn-text-icon',
221                                         text : "Add",
222                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
223                                     },
224                                     {
225                                         xtype: 'Button',
226                                         xns: Roo.Toolbar,
227                                         listeners : {
228                                             click : function()
229                                             {
230                                                  var s = _this.grid.getSelectionModel().getSelected();
231                                                  
232                                                  if(!s || s.data.vend_id * 1 < 1){
233                                                     Roo.MessageBox.alert('Error', 'Please select a row');
234                                                     return;
235                                                  }
236                                                  
237                                                  Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
238                                                     function(v) {
239                                                         if (v != 'yes') {
240                                                             return;
241                                                         }
242                                                          new Pman.Request({
243                                                             method: 'POST',
244                                                             url: baseURL+ '/Roo/vendinfo',
245                                                             params : {
246                                                                 _delete : s.data.vend_id
247                                                             },
248                                                             success : function() {
249                                                                 _this.grid.footer.onClick('refresh');
250                                                             }
251                                                         });
252                                                 });
253                                             }
254                                         },
255                                         cls : 'x-btn-text-icon',
256                                         text : "Delete",
257                                         icon : rootURL + '/Pman/templates/images/trash.gif'
258                                     },
259                                     {
260                                         xtype: 'Button',
261                                         xns: Roo.Toolbar,
262                                         menu : {
263                                             xtype: 'Menu',
264                                             xns: Roo.menu,
265                                             items : [
266                                                 {
267                                                     xtype: 'Item',
268                                                     xns: Roo.menu,
269                                                     listeners : {
270                                                         click : function (_self, e)
271                                                         {
272                                                            Pman.Dialog.Image.show(
273                                                                {
274                                                                     _url : baseURL+'/Xtuple/Import/Vendors' 
275                                                                 
276                                                                },
277                                                                function (data) {
278                                                                     _this.grid.footer.onClick('first');
279                                                                     Roo.MessageBox.alert("Notice", "DONE");
280                                                         //            Roo.MessageBox.alert("Notice", msg.join("\n"));
281                                                         
282                                                                }
283                                                            );
284                                                         }
285                                                     },
286                                                     text : "Normal Vendors"
287                                                 },
288                                                 {
289                                                     xtype: 'Item',
290                                                     xns: Roo.menu,
291                                                     listeners : {
292                                                         click : function (_self, e)
293                                                         {
294                                                            Pman.Dialog.Image.show(
295                                                                {
296                                                                     _url : baseURL+'/Xtuple/Import/ShopVendors' 
297                                                                 
298                                                                },
299                                                                function (data) {
300                                                                     _this.grid.footer.onClick('first');
301                                                                     Roo.MessageBox.alert("Notice", "DONE");
302                                                         //            Roo.MessageBox.alert("Notice", msg.join("\n"));
303                                                         
304                                                                }
305                                                            );
306                                                         }
307                                                     },
308                                                     text : "Shop Vendors"
309                                                 }
310                                             ]
311                                         }
312                                     }
313                                 ]
314                             },
315                             colModel : [
316                                 {
317                                     xtype: 'ColumnModel',
318                                     xns: Roo.grid,
319                                     dataIndex : 'vend_name',
320                                     header : 'Name',
321                                     width : 100,
322                                     renderer : function(v) { return String.format('{0}', v); }
323                                 },
324                                 {
325                                     xtype: 'ColumnModel',
326                                     xns: Roo.grid,
327                                     dataIndex : 'vend_vendtype_id_vendtype_descrip',
328                                     header : 'Type',
329                                     width : 150,
330                                     renderer : function(v) { return String.format('{0}', v); }
331                                 },
332                                 {
333                                     xtype: 'ColumnModel',
334                                     xns: Roo.grid,
335                                     dataIndex : 'vend_char_internalcompany',
336                                     header : 'Internal?',
337                                     width : 100,
338                                     renderer : function(v) { return String.format('{0}', v ? v : ''); }
339                                 }
340                             ]
341                         }
342                     }
343                 ],
344                 center : {
345                     xtype: 'LayoutRegion',
346                     xns: Roo
347                 }
348             }
349         };
350     }
351 });