Pman.Tab.XtuplePriceLists.bjs
[Pman.Xtuple] / Pman.Tab.XtuplePriceLists.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.XtuplePriceLists = new Roo.XComponent({
6     part     :  ["Xtuple","PriceLists"],
7     order    : '001-Pman.Tab.XtuplePriceLists',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleManage',
10     name     : "Pman.Tab.XtuplePriceLists",
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 : "Price List",
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 : true,
41                         fitContainer : true,
42                         fitToframe : true,
43                         region : 'center',
44                         tableName : 'ipshead',
45                         title : "Price Lists",
46                         grid : {
47                             xtype: 'Grid',
48                             xns: Roo.grid,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     _this.dialog = Pman.Dialog.XtuplePriceList
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 },
58                                 rowdblclick : function (_self, rowIndex, e)
59                                 {
60                                     if (!_this.dialog) return;
61                                     _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
62                                         _this.grid.footer.onClick('first');
63                                     }); 
64                                     
65                                 }
66                             },
67                             autoExpandColumn : 'ipshead_descrip',
68                             loadMask : true,
69                             sm : {
70                                 xtype: 'RowSelectionModel',
71                                 xns: Roo.grid,
72                                 listeners : {
73                                     selectionchange : function (_self)
74                                     {
75                                         _this.igrid.footer.onClick('first');
76                                     }
77                                 },
78                                 singleSelect : true
79                             },
80                             dataSource : {
81                                 xtype: 'Store',
82                                 xns: Roo.data,
83                                 remoteSort : true,
84                                 sortInfo : { field : 'ipshead_name', direction: 'ASC' },
85                                 proxy : {
86                                     xtype: 'HttpProxy',
87                                     xns: Roo.data,
88                                     method : 'GET',
89                                     url : baseURL + '/Roo/ipshead.php'
90                                 },
91                                 reader : {
92                                     xtype: 'JsonReader',
93                                     xns: Roo.data,
94                                     totalProperty : 'total',
95                                     root : 'data',
96                                     id : 'id',
97                                     fields : [
98                                         {
99                                             'name': 'ipshead_id',
100                                             'type': 'int'
101                                         },
102                                         {
103                                             'name': 'ipshead_name',
104                                             'type': 'string'
105                                         },
106                                         {
107                                             'name': 'ipshead_descrip',
108                                             'type': 'string'
109                                         },
110                                         {
111                                             'name': 'ipshead_effective',
112                                             'type': 'date',
113                                             'dateFormat': 'Y-m-d'
114                                         },
115                                         {
116                                             'name': 'ipshead_expires',
117                                             'type': 'date',
118                                             'dateFormat': 'Y-m-d'
119                                         },
120                                         {
121                                             'name': 'ipshead_curr_id',
122                                             'type': 'int'
123                                         },
124                                         {
125                                             'name': 'ipshead_updated',
126                                             'type': 'date',
127                                             'dateFormat': 'Y-m-d'
128                                         },
129                                         {
130                                             'name': 'ipshead_curr_id_curr_id',
131                                             'type': 'int'
132                                         },
133                                         {
134                                             'name': 'ipshead_curr_id_curr_base',
135                                             'type': 'int'
136                                         },
137                                         {
138                                             'name': 'ipshead_curr_id_curr_name',
139                                             'type': 'string'
140                                         },
141                                         {
142                                             'name': 'ipshead_curr_id_curr_symbol',
143                                             'type': 'string'
144                                         },
145                                         {
146                                             'name': 'ipshead_curr_id_curr_abbr',
147                                             'type': 'string'
148                                         }
149                                     ]
150                                 }
151                             },
152                             footer : {
153                                 xtype: 'PagingToolbar',
154                                 xns: Roo,
155                                 displayInfo : true,
156                                 displayMsg : "Displaying ipshead{0} - {1} of {2}",
157                                 emptyMsg : "No ipshead found",
158                                 pageSize : 25
159                             },
160                             toolbar : {
161                                 xtype: 'Toolbar',
162                                 xns: Roo,
163                                 items : [
164                                     {
165                                         xtype: 'Button',
166                                         xns: Roo.Toolbar,
167                                         listeners : {
168                                             click : function (_self, e)
169                                             {
170                                                new Pman.Download({
171                                                     method: 'GET',
172                                                     url : baseURL + '/Roo/Ipsiteminfo',
173                                                     params : {
174                                                         _pricegrid : 1
175                                                     }
176                                                });
177                                             }
178                                         },
179                                         text : "Download Price Matrix"
180                                     },
181                                     {
182                                         xtype: 'Button',
183                                         xns: Roo.Toolbar,
184                                         listeners : {
185                                             click : function (_self, e)
186                                             {
187                                                Pman.Dialog.Image.show(
188                                                    {
189                                                         _url : baseURL+'/Xtuple/Pricing'
190                                                     
191                                                    },
192                                                    function (data) {
193                                                         var msg = [];
194                                                         if (data.deleted) {
195                                                             msg.push("Deleted " + data.deleted + " Price(s)");
196                                                         }
197                                                         if (data.updated) {
198                                                             msg.push("Updated " + data.updated + " Price(s)");
199                                                         }            
200                                                         if (data.inserted) {
201                                                             msg.push("Added " + data.inserted + " Price(s)");
202                                                         }
203                                                         if (!msg.length) {
204                                                             msg.push("No data changed");
205                                                         }
206                                                         Roo.MessageBox.alert("Notice", msg.join("\n"));
207                                             
208                                                    }
209                                                );
210                                             }
211                                         },
212                                         text : "Upload Price Matrix"
213                                     },
214                                     {
215                                         xtype: 'Fill',
216                                         xns: Roo.Toolbar
217                                     },
218                                     {
219                                         xtype: 'Button',
220                                         xns: Roo.Toolbar,
221                                         text : "Add",
222                                         cls : 'x-btn-text-icon',
223                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
224                                         listeners : {
225                                             click : function()
226                                             {
227                                                 if (!_this.dialog) return;
228                                                 _this.dialog.show( { id : 0 } , function() {
229                                                     _this.grid.footer.onClick('first');
230                                                }); 
231                                             }
232                                         }
233                                     },
234                                     {
235                                         xtype: 'Button',
236                                         xns: Roo.Toolbar,
237                                         text : "Delete",
238                                         cls : 'x-btn-text-icon',
239                                         icon : rootURL + '/Pman/templates/images/trash.gif',
240                                         listeners : {
241                                             click : function()
242                                             {
243                                                  Pman.genericDelete(_this, 'ipshead'); 
244                                             }
245                                         }
246                                     }
247                                 ]
248                             },
249                             colModel : [
250                                 {
251                                     xtype: 'ColumnModel',
252                                     xns: Roo.grid,
253                                     dataIndex : 'ipshead_curr_id_curr_name',
254                                     header : 'Ipshead curr',
255                                     sortable : true,
256                                     width : 75,
257                                     renderer : function(v) { return String.format('{0}', v); }
258                                 },
259                                 {
260                                     xtype: 'ColumnModel',
261                                     xns: Roo.grid,
262                                     dataIndex : 'ipshead_name',
263                                     header : 'Ipshead name',
264                                     sortable : true,
265                                     width : 200,
266                                     renderer : function(v) { return String.format('{0}', v); }
267                                 },
268                                 {
269                                     xtype: 'ColumnModel',
270                                     xns: Roo.grid,
271                                     header : 'Ipshead descrip',
272                                     width : 200,
273                                     dataIndex : 'ipshead_descrip',
274                                     renderer : function(v) { return String.format('{0}', v); }
275                                 },
276                                 {
277                                     xtype: 'ColumnModel',
278                                     xns: Roo.grid,
279                                     header : 'Ipshead effective',
280                                     width : 75,
281                                     dataIndex : 'ipshead_effective',
282                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
283                                 },
284                                 {
285                                     xtype: 'ColumnModel',
286                                     xns: Roo.grid,
287                                     dataIndex : 'ipshead_expires',
288                                     header : 'Ipshead expires',
289                                     width : 75,
290                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
291                                 },
292                                 {
293                                     xtype: 'ColumnModel',
294                                     xns: Roo.grid,
295                                     header : 'Ipshead updated',
296                                     width : 75,
297                                     dataIndex : 'ipshead_updated',
298                                     renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
299                                 }
300                             ]
301                         }
302                     },
303                     {
304                         xtype: 'GridPanel',
305                         xns: Roo,
306                         listeners : {
307                             activate : function() {
308                                 _this.ipanel = this;
309                                 if (_this.igrid) {
310                                    // _this.igrid.footer.onClick('first');
311                                 }
312                             }
313                         },
314                         background : true,
315                         fitContainer : true,
316                         fitToframe : true,
317                         region : 'east',
318                         tableName : 'item',
319                         title : "Products",
320                         grid : {
321                             xtype: 'EditorGrid',
322                             xns: Roo.grid,
323                             listeners : {
324                                 render : function() 
325                                 {
326                                     _this.igrid = this; 
327                                     //_this.dialog = Pman.Dialog.FILL_IN
328                                     if (_this.ipanel.active) {
329                                        //this.footer.onClick('first');
330                                     }
331                                 },
332                                 afteredit : function (e)
333                                 {
334                                     Roo.log(e);    
335                                     /*
336                                 
337                                     new Pman.Request({
338                                         url : baseURL +'/Roo/Charass',
339                                         params : {
340                                              charass_char_id_char_name : e.field.replace(/^item_char_/,'').toUpperCase(),
341                                              charass_value : e.value,
342                                              charass_target_type : 'I',
343                                              charass_default : 1,
344                                              charass_target_id : e.record.data.item_id
345                                          },
346                                          method : 'POST'
347                                      });
348                                     
349                                     
350                                     e.record.commit();
351                                     */
352                                     
353                                     
354                                 },
355                                 beforeedit : function (e)
356                                 {
357                                     if(e.field != 'ipshead_price'){
358                                         return false;
359                                     }
360                                 
361                                 }
362                             },
363                             autoExpandColumn : 'item_number',
364                             clicksToEdit : 1,
365                             loadMask : true,
366                             dataSource : {
367                                 xtype: 'Store',
368                                 xns: Roo.data,
369                                 listeners : {
370                                     beforeload : function (_self, o)
371                                     {
372                                         o.params = o.params || {}
373                                         
374                                         var p = _this.grid.getSelectionModel().getSelected();
375                                         
376                                         if(!p || p.data.ipshead_id * 1 < 1){
377                                             this.removeAll();
378                                             return false;
379                                         }
380                                         
381                                         o.params.item_active = 1;
382                                         o.params._ipshead_price = 1;
383                                         o.params._ipshead_id = p.data.ipshead_id;
384                                     
385                                     },
386                                     update : function (_self, record, operation)
387                                     {
388                                         if(operation != 'commit'){
389                                             return;
390                                         }
391                                         
392                                         var nv  = record.data.itemsrc_active ? 0 : 1;
393                                         new Pman.Request({
394                                             mask : 'Saving',
395                                             url : baseURL + '/Roo/Itemsrc',
396                                             params : {
397                                                 _update_by_item : 1,
398                                                 item_id : record.data.item_id,
399                                                 itemsrc_active : nv
400                                             },
401                                             success : function(res) {
402                                                 record.set('itemsrc_active', nv);
403                                             }
404                                         });
405                                     }
406                                 },
407                                 remoteSort : true,
408                                 sortInfo : { field : 'item_number', direction: 'ASC' },
409                                 proxy : {
410                                     xtype: 'HttpProxy',
411                                     xns: Roo.data,
412                                     method : 'GET',
413                                     url : baseURL + '/Roo/item.php'
414                                 },
415                                 reader : {
416                                     xtype: 'JsonReader',
417                                     xns: Roo.data,
418                                     id : 'id',
419                                     root : 'data',
420                                     totalProperty : 'total',
421                                     fields : [
422                                         {
423                                             'name': 'item_id',
424                                             'type': 'int'
425                                         },
426                                         {
427                                             'name': 'item_number',
428                                             'type': 'string'
429                                         }
430                                     ]
431                                 }
432                             },
433                             footer : {
434                                 xtype: 'PagingToolbar',
435                                 xns: Roo,
436                                 displayInfo : true,
437                                 displayMsg : "",
438                                 emptyMsg : "",
439                                 pageSize : 25
440                             },
441                             colModel : [
442                                 {
443                                     xtype: 'ColumnModel',
444                                     xns: Roo.grid,
445                                     dataIndex : 'item_number',
446                                     header : 'Number',
447                                     width : 150,
448                                     renderer : function(v) { return String.format('{0}', v); }
449                                 },
450                                 {
451                                     xtype: 'ColumnModel',
452                                     xns: Roo.grid,
453                                     align : 'right',
454                                     dataIndex : 'ipshead_price',
455                                     header : 'Price',
456                                     width : 100,
457                                     renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
458                                     editor : {
459                                         xtype: 'GridEditor',
460                                         xns: Roo.grid,
461                                         field : {
462                                             xtype: 'NumberField',
463                                             xns: Roo.form,
464                                             decimalPrecision : 2,
465                                             minValue : 1,
466                                             style : 'text-align:right'
467                                         }
468                                     }
469                                 }
470                             ]
471                         }
472                     }
473                 ],
474                 center : {
475                     xtype: 'LayoutRegion',
476                     xns: Roo
477                 },
478                 east : {
479                     xtype: 'LayoutRegion',
480                     xns: Roo,
481                     split : true,
482                     width : 350
483                 }
484             }
485         };
486     }
487 });