Fix #7123 - getting abra ready to test
[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                                     afterselectionchange : 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                                     if(e.value == e.originalValue){
335                                         return false;       
336                                     }
337                                     
338                                     var p = _this.grid.getSelectionModel().getSelected();
339                                     
340                                     if(!p || p.data.ipshead_id * 1 < 1){
341                                         Roo.MessageBox.alert('Error','Please select a price list');
342                                         return false;       
343                                     }
344                                     
345                                     new Pman.Request({
346                                         url : baseURL +'/Roo/Item',
347                                         method : 'POST',
348                                         marks : 'Posting',
349                                         params : {
350                                              update_ipshead : 1,
351                                              ipshead_id : p.data.ipshead_id,
352                                              item_id : e.record.data.item_id,
353                                              _price : e.value,
354                                          },
355                                          success : function() {
356                                             _this.igrid.footer.onClick('refresh');
357                                         }
358                                          
359                                      });
360                                     
361                                 },
362                                 beforeedit : function (e)
363                                 {
364                                     if(e.field != 'ipshead_price'){
365                                         return false;
366                                     }
367                                 
368                                 }
369                             },
370                             autoExpandColumn : 'item_number',
371                             clicksToEdit : 1,
372                             loadMask : true,
373                             dataSource : {
374                                 xtype: 'Store',
375                                 xns: Roo.data,
376                                 listeners : {
377                                     beforeload : function (_self, o)
378                                     {
379                                         o.params = o.params || {}
380                                         
381                                         var p = _this.grid.getSelectionModel().getSelected();
382                                         
383                                         if(!p || p.data.ipshead_id * 1 < 1){
384                                             this.removeAll();
385                                             return false;
386                                         }
387                                         
388                                         //o.params.item_active = 1;
389                                         o.params._ipshead_price = 1;
390                                         o.params._ipshead_id = p.data.ipshead_id;
391                                     
392                                     }
393                                 },
394                                 remoteSort : true,
395                                 sortInfo : { field : 'item_number', direction: 'ASC' },
396                                 proxy : {
397                                     xtype: 'HttpProxy',
398                                     xns: Roo.data,
399                                     method : 'GET',
400                                     url : baseURL + '/Roo/item.php'
401                                 },
402                                 reader : {
403                                     xtype: 'JsonReader',
404                                     xns: Roo.data,
405                                     id : 'id',
406                                     root : 'data',
407                                     totalProperty : 'total',
408                                     fields : [
409                                         {
410                                             'name': 'item_id',
411                                             'type': 'int'
412                                         },
413                                         {
414                                             'name': 'item_number',
415                                             'type': 'string'
416                                         }
417                                     ]
418                                 }
419                             },
420                             footer : {
421                                 xtype: 'PagingToolbar',
422                                 xns: Roo,
423                                 displayInfo : true,
424                                 displayMsg : "",
425                                 emptyMsg : "",
426                                 pageSize : 25
427                             },
428                             colModel : [
429                                 {
430                                     xtype: 'ColumnModel',
431                                     xns: Roo.grid,
432                                     dataIndex : 'item_number',
433                                     header : 'Number',
434                                     width : 150,
435                                     renderer : function(v) { return String.format('{0}', v); }
436                                 },
437                                 {
438                                     xtype: 'ColumnModel',
439                                     xns: Roo.grid,
440                                     align : 'right',
441                                     dataIndex : 'ipshead_price',
442                                     header : 'Price',
443                                     width : 100,
444                                     renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
445                                     editor : {
446                                         xtype: 'GridEditor',
447                                         xns: Roo.grid,
448                                         field : {
449                                             xtype: 'NumberField',
450                                             xns: Roo.form,
451                                             decimalPrecision : 2,
452                                             minValue : 1,
453                                             style : 'text-align:right'
454                                         }
455                                     }
456                                 }
457                             ]
458                         }
459                     }
460                 ],
461                 center : {
462                     xtype: 'LayoutRegion',
463                     xns: Roo
464                 },
465                 east : {
466                     xtype: 'LayoutRegion',
467                     xns: Roo,
468                     split : true,
469                     width : 350
470                 }
471             }
472         };
473     }
474 });