erp_products 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/app/controllers/erp_products/erp_app/desktop/product_manager/base_controller.rb +1 -1
  2. data/app/models/product_type.rb +2 -2
  3. data/lib/erp_products/engine.rb +7 -1
  4. data/lib/erp_products/version.rb +7 -1
  5. data/lib/erp_products.rb +1 -0
  6. data/public/javascripts/erp_app/desktop/applications/product_manager/module.js +713 -718
  7. data/public/javascripts/erp_app/desktop/applications/product_manager/product_list_panel.js +127 -128
  8. data/spec/dummy/Rakefile +7 -0
  9. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  10. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  12. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  13. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  14. data/spec/dummy/config/application.rb +49 -0
  15. data/spec/dummy/config/boot.rb +10 -0
  16. data/spec/dummy/config/database.yml +8 -0
  17. data/spec/dummy/config/environment.rb +5 -0
  18. data/spec/dummy/config/environments/spec.rb +27 -0
  19. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  20. data/spec/dummy/config/initializers/inflections.rb +10 -0
  21. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  22. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  23. data/spec/dummy/config/initializers/session_store.rb +8 -0
  24. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  25. data/spec/dummy/config/locales/en.yml +5 -0
  26. data/spec/dummy/config/routes.rb +3 -0
  27. data/spec/dummy/config.ru +4 -0
  28. data/spec/dummy/public/404.html +26 -0
  29. data/spec/dummy/public/422.html +26 -0
  30. data/spec/dummy/public/500.html +26 -0
  31. data/spec/dummy/public/favicon.ico +0 -0
  32. data/spec/dummy/script/rails +6 -0
  33. data/spec/models/prod_availability_status_type_spec.rb +11 -0
  34. data/spec/models/prod_instance_reln_spec.rb +11 -0
  35. data/spec/models/prod_instance_reln_type_spec.rb +11 -0
  36. data/spec/models/prod_instance_role_type_spec.rb +11 -0
  37. data/spec/models/prod_type_reln_spec.rb +11 -0
  38. data/spec/models/prod_type_reln_type_spec.rb +12 -0
  39. data/spec/models/prod_type_role_type_spec.rb +12 -0
  40. data/spec/models/product_instance_spec.rb +13 -0
  41. data/spec/models/product_offer_spec.rb +12 -0
  42. data/spec/models/product_package_spec.rb +12 -0
  43. data/spec/models/product_type_spec.rb +13 -0
  44. data/spec/models/simple_product_offer_spec.rb +14 -0
  45. data/spec/spec_helper.rb +60 -0
  46. metadata +110 -34
@@ -1,41 +1,39 @@
1
- Ext.ns("Compass.ErpApp.Desktop.Applications");
2
-
3
1
  //
4
2
  //module
5
3
  //
6
4
 
7
5
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager",{
8
- extend:"Ext.ux.desktop.Module",
9
- id:'product_manager-win',
10
- init : function(){
11
- this.launcher = {
12
- text: 'Products',
13
- iconCls:'icon-product',
14
- handler : this.createWindow,
15
- scope: this
16
- }
17
- },
18
- createWindow : function(){
19
- var desktop = this.app.getDesktop();
20
- var win = desktop.getWindow('product_manager');
21
- if(!win){
22
- win = desktop.createWindow({
23
- id: 'product_manager',
24
- title:'Products',
25
- width:1000,
26
- height:550,
27
- iconCls: 'icon-product',
28
- shim:false,
29
- animCollapse:false,
30
- constrainHeader:true,
31
- layout: 'fit',
32
- items:[{
33
- xtype:'productmanagement_productspanel'
34
- }]
35
- });
36
- }
37
- win.show();
6
+ extend:"Ext.ux.desktop.Module",
7
+ id:'product_manager-win',
8
+ init : function(){
9
+ this.launcher = {
10
+ text: 'Products',
11
+ iconCls:'icon-product',
12
+ handler : this.createWindow,
13
+ scope: this
38
14
  }
15
+ },
16
+ createWindow : function(){
17
+ var desktop = this.app.getDesktop();
18
+ var win = desktop.getWindow('product_manager');
19
+ if(!win){
20
+ win = desktop.createWindow({
21
+ id: 'product_manager',
22
+ title:'Products',
23
+ width:1000,
24
+ height:550,
25
+ iconCls: 'icon-product',
26
+ shim:false,
27
+ animCollapse:false,
28
+ constrainHeader:true,
29
+ layout: 'fit',
30
+ items:[{
31
+ xtype:'productmanagement_productspanel'
32
+ }]
33
+ });
34
+ }
35
+ win.show();
36
+ }
39
37
  });
40
38
 
41
39
  //
@@ -43,102 +41,103 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager",{
43
41
  //
44
42
 
45
43
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm",{
46
- extend:"Ext.form.Panel",
47
- alias:'widget.productmanager_productdescriptionform',
48
- initComponent: function() {
49
- Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm.superclass.initComponent.call(this, arguments);
44
+ extend:"Ext.form.Panel",
45
+ alias:'widget.productmanager_productdescriptionform',
46
+ initComponent: function() {
47
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm.superclass.initComponent.call(this, arguments);
50
48
 
51
- this.addEvents(
52
- /**
49
+ this.addEvents(
50
+ /**
53
51
  * @event saved
54
52
  * Fired after form is saved.
55
53
  * @param {Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm} form this object
56
54
  * @param {integer} Newly create id
57
55
  */
58
- 'saved'
59
- );
60
- },
61
-
62
- constructor : function(config) {
63
- var self = this;
64
- config = Ext.apply({
65
- buttonAlign:'center',
66
- bodyStyle:'padding:5px 5px 0',
67
- items: [
68
- {
69
- fieldLabel:'Title',
70
- xtype:'textfield',
71
- allowBlank:false,
72
- width:500,
73
- name:'title'
74
-
75
- },
76
- {
77
- xtype : 'label',
78
- html : 'Describe your product:',
79
- cls : "x-form-item x-form-item-label card-label"
80
- },
81
- {
82
- xtype: 'ckeditor',
83
- allowBlank:false,
84
- ckEditorConfig:{
85
- height:'345px',
86
- width:750,
87
- extraPlugins:'jwplayer',
88
- toolbar:[
89
- ['Source','-','CompassSave','Preview','Print','-','Templates',
90
- 'Cut','Copy','Paste','PasteText','PasteFromWord','Undo','Redo'],
91
- ['Find','Replace','SpellChecker', 'Scayt','-','SelectAll'],
92
- ['TextColor','BGColor'],
93
- ['Bold','Italic','Underline','Strike','-','Subscript','Superscript','-','RemoveFormat'],
94
- ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
95
- '/',
96
- ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
97
- ['BidiLtr', 'BidiRtl' ],
98
- ['Link','Unlink','Anchor'],
99
- ['jwplayer','Flash','Table','HorizontalRule',,'SpecialChar','PageBreak',],
100
- [ 'Styles','Format','Font','FontSize' ],
101
- ['Maximize', 'ShowBlocks','-','About']
102
- ]
103
- }
56
+ 'saved'
57
+ );
58
+ },
59
+
60
+ constructor : function(config) {
61
+ var self = this;
62
+ config = Ext.apply({
63
+ buttonAlign:'center',
64
+ bodyStyle:'padding:5px 5px 0',
65
+ items: [
66
+ {
67
+ fieldLabel:'Title',
68
+ xtype:'textfield',
69
+ allowBlank:false,
70
+ width:500,
71
+ name:'title'
72
+
73
+ },
74
+ {
75
+ xtype : 'label',
76
+ html : 'Describe your product:',
77
+ cls : "x-form-item x-form-item-label card-label"
78
+ },
79
+ {
80
+ xtype: 'ckeditor',
81
+ allowBlank:false,
82
+ autoHeight:true,
83
+ ckEditorConfig:{
84
+ height:'290px',
85
+ width:750,
86
+ extraPlugins:'jwplayer',
87
+ toolbar:[
88
+ ['Source','-','CompassSave','Preview','Print','-','Templates',
89
+ 'Cut','Copy','Paste','PasteText','PasteFromWord','Undo','Redo'],
90
+ ['Find','Replace','SpellChecker', 'Scayt','-','SelectAll'],
91
+ ['TextColor','BGColor'],
92
+ ['Bold','Italic','Underline','Strike','-','Subscript','Superscript','-','RemoveFormat'],
93
+ ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
94
+ '/',
95
+ ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
96
+ ['BidiLtr', 'BidiRtl' ],
97
+ ['Link','Unlink','Anchor'],
98
+ ['jwplayer','Flash','Table','HorizontalRule',,'SpecialChar','PageBreak',],
99
+ [ 'Styles','Format','Font','FontSize' ],
100
+ ['Maximize', 'ShowBlocks','-','About']
101
+ ]
102
+ }
103
+ },
104
+ {
105
+ xtype:'hidden',
106
+ name:'description'
107
+ }
108
+ ],
109
+ buttons:[
110
+ {
111
+ text:'Save',
112
+ handler:function(btn){
113
+ var formPanel = btn.findParentByType('form');
114
+ var basicForm = formPanel.getForm();
115
+
116
+ //ckeditor does not post. Get the value and set to hidden field
117
+ var ckeditor = formPanel.query('ckeditor').first();
118
+ basicForm.findField('description').setValue(ckeditor.getValue());
119
+
120
+ basicForm.submit({
121
+ success:function(form, action){
122
+ var obj = Ext.decode(action.response.responseText);
123
+ if(obj.success){
124
+ self.fireEvent('saved', this, obj.id);
125
+ }
126
+ else{
127
+ Ext.Msg.alert("Error", 'Error creating product');
128
+ }
104
129
  },
105
- {
106
- xtype:'hidden',
107
- name:'description'
108
- }
109
- ],
110
- buttons:[
111
- {
112
- text:'Save',
113
- handler:function(btn){
114
- var formPanel = btn.findParentByType('form');
115
- var basicForm = formPanel.getForm();
116
-
117
- //ckeditor does not post. Get the value and set to hidden field
118
- var ckeditor = formPanel.query('ckeditor')[0];
119
- basicForm.findField('description').setValue(ckeditor.getValue());
120
-
121
- basicForm.submit({
122
- success:function(form, action){
123
- var obj = Ext.decode(action.response.responseText);
124
- if(obj.success){
125
- self.fireEvent('saved', this, obj.id);
126
- }
127
- else{
128
- Ext.Msg.alert("Error", 'Error creating product');
129
- }
130
- },
131
- failure:function(form, action){
132
- Ext.Msg.alert("Error", 'Error creating product');
133
- }
134
- });
135
- }
130
+ failure:function(form, action){
131
+ Ext.Msg.alert("Error", 'Error creating product');
136
132
  }
137
- ]
138
- }, config);
133
+ });
134
+ }
135
+ }
136
+ ]
137
+ }, config);
139
138
 
140
- Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm.superclass.constructor.call(this, config);
141
- }
139
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm.superclass.constructor.call(this, config);
140
+ }
142
141
  });
143
142
 
144
143
  //
@@ -146,331 +145,330 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptio
146
145
  //
147
146
 
148
147
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel",{
149
- extend:"Ext.panel.Panel",
150
- alias:'widget.productmanager_productpricingpanel',
151
- updatePrice : function(rec){
152
- this.addEditPriceBtn.setText('Update Price');
153
- this.cancelBtn.show();
154
- this.addPriceFormPanel.getForm().setValues(rec.data);
155
- },
156
-
157
- deletePrice : function(rec){
158
- var self = this;
159
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this price?', function(btn){
160
- if(btn == 'no'){
161
- return false;
148
+ extend:"Ext.panel.Panel",
149
+ alias:'widget.productmanager_productpricingpanel',
150
+ updatePrice : function(rec){
151
+ this.addEditPriceBtn.setText('Update Price');
152
+ this.cancelBtn.show();
153
+ this.addPriceFormPanel.getForm().setValues(rec.data);
154
+ },
155
+
156
+ deletePrice : function(rec){
157
+ var self = this;
158
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this price?', function(btn){
159
+ if(btn == 'no'){
160
+ return false;
161
+ }
162
+ else
163
+ {
164
+ Ext.Ajax.request({
165
+ url: '/erp_products/erp_app/desktop/product_manager/delete_price/'+rec.get('pricing_plan_id'),
166
+ success: function(response) {
167
+ var obj = Ext.decode(response.responseText);
168
+ if(obj.success){
169
+ Ext.getCmp('productListPanel').loadProducts();
170
+ self.pricesGridPanel.getStore().load();
162
171
  }
163
- else
164
- {
165
- var conn = new Ext.data.Connection();
166
- conn.request({
167
- url: '/erp_products/erp_app/desktop/product_manager/delete_price/'+rec.get('pricing_plan_id'),
168
- success: function(response) {
169
- var obj = Ext.decode(response.responseText);
170
- if(obj.success){
171
- Ext.getCmp('productListPanel').loadProducts();
172
- self.pricesGridPanel.getStore().load();
173
- }
174
- else{
175
- Ext.Msg.alert('Error', 'Error deleting price.');
176
- }
177
- },
178
- failure: function(response) {
179
- Ext.Msg.alert('Error', 'Error deleting price.');
180
- }
181
- });
172
+ else{
173
+ Ext.Msg.alert('Error', 'Error deleting price.');
182
174
  }
175
+ },
176
+ failure: function(response) {
177
+ Ext.Msg.alert('Error', 'Error deleting price.');
178
+ }
183
179
  });
184
- },
185
-
186
- initComponent: function() {
187
- Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel.superclass.initComponent.call(this, arguments);
188
- },
189
-
190
- constructor : function(config) {
191
- var self = this;
192
-
193
- this.pricesGridPanel = Ext.create("Ext.grid.Panel",{
194
- layout:'fit',
195
- region:'center',
196
- split:true,
197
- columns: [
198
- {
199
- header:'Description',
200
- width:310,
201
- sortable: false,
202
- dataIndex: 'description'
203
- },
204
- {
205
- header: 'Price',
206
- width: 75,
207
- sortable: true,
208
- dataIndex: 'price',
209
- renderer:function(v){
210
- return v.toFixed(2);
211
- }
212
- },
213
- {
214
- header: 'Currency',
215
- width: 75,
216
- sortable: true,
217
- dataIndex: 'currency_display'
218
- },
219
- {
220
- header: 'From Date',
221
- width: 90,
222
- sortable: true,
223
- dataIndex: 'from_date',
224
- renderer: Ext.util.Format.dateRenderer('m/d/Y')
225
- },
226
- {
227
- header: 'Thru Date',
228
- width: 90,
229
- sortable: true,
230
- dataIndex: 'thru_date',
231
- renderer: Ext.util.Format.dateRenderer('m/d/Y')
232
- },
233
- {
234
- menuDisabled:true,
235
- resizable:false,
236
- xtype:'actioncolumn',
237
- header:'Update',
238
- align:'center',
239
- width:60,
240
- items:[{
241
- icon:'/images/icons/edit/edit_16x16.png',
242
- tooltip:'Update',
243
- handler :function(grid, rowIndex, colIndex){
244
- var rec = grid.getStore().getAt(rowIndex);
245
- self.updatePrice(rec);
246
- }
247
- }]
248
- },
249
- {
250
- menuDisabled:true,
251
- resizable:false,
252
- xtype:'actioncolumn',
253
- header:'Delete',
254
- align:'center',
255
- width:60,
256
- items:[{
257
- icon:'/images/icons/delete/delete_16x16.png',
258
- tooltip:'Delete',
259
- handler :function(grid, rowIndex, colIndex){
260
- var rec = grid.getStore().getAt(rowIndex);
261
- self.deletePrice(rec);
262
- }
263
- }]
264
- },
265
- {
266
- menuDisabled:true,
267
- resizable:false,
268
- xtype:'actioncolumn',
269
- header:'Comment',
270
- align:'center',
271
- width:60,
272
- items:[{
273
- getClass: function(v, meta, rec) { // Or return a class from a function
274
- this.items[0].tooltip = rec.get('comments');
275
- return 'info-col';
276
- },
277
- handler: function(grid, rowIndex, colIndex) {
278
- return false;
279
- }
280
- }]
180
+ }
181
+ });
182
+ },
183
+
184
+ initComponent: function() {
185
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel.superclass.initComponent.call(this, arguments);
186
+ },
187
+
188
+ constructor : function(config) {
189
+ var self = this;
190
+
191
+ this.pricesGridPanel = Ext.create("Ext.grid.Panel",{
192
+ layout:'fit',
193
+ region:'center',
194
+ split:true,
195
+ columns: [
196
+ {
197
+ header:'Description',
198
+ width:310,
199
+ sortable: false,
200
+ dataIndex: 'description'
201
+ },
202
+ {
203
+ header: 'Price',
204
+ width: 75,
205
+ sortable: true,
206
+ dataIndex: 'price',
207
+ renderer:function(v){
208
+ return v.toFixed(2);
209
+ }
210
+ },
211
+ {
212
+ header: 'Currency',
213
+ width: 75,
214
+ sortable: true,
215
+ dataIndex: 'currency_display'
216
+ },
217
+ {
218
+ header: 'From Date',
219
+ width: 90,
220
+ sortable: true,
221
+ dataIndex: 'from_date',
222
+ renderer: Ext.util.Format.dateRenderer('m/d/Y')
223
+ },
224
+ {
225
+ header: 'Thru Date',
226
+ width: 90,
227
+ sortable: true,
228
+ dataIndex: 'thru_date',
229
+ renderer: Ext.util.Format.dateRenderer('m/d/Y')
230
+ },
231
+ {
232
+ menuDisabled:true,
233
+ resizable:false,
234
+ xtype:'actioncolumn',
235
+ header:'Update',
236
+ align:'center',
237
+ width:60,
238
+ items:[{
239
+ icon:'/images/icons/edit/edit_16x16.png',
240
+ tooltip:'Update',
241
+ handler :function(grid, rowIndex, colIndex){
242
+ var rec = grid.getStore().getAt(rowIndex);
243
+ self.updatePrice(rec);
244
+ }
245
+ }]
246
+ },
247
+ {
248
+ menuDisabled:true,
249
+ resizable:false,
250
+ xtype:'actioncolumn',
251
+ header:'Delete',
252
+ align:'center',
253
+ width:60,
254
+ items:[{
255
+ icon:'/images/icons/delete/delete_16x16.png',
256
+ tooltip:'Delete',
257
+ handler :function(grid, rowIndex, colIndex){
258
+ var rec = grid.getStore().getAt(rowIndex);
259
+ self.deletePrice(rec);
260
+ }
261
+ }]
262
+ },
263
+ {
264
+ menuDisabled:true,
265
+ resizable:false,
266
+ xtype:'actioncolumn',
267
+ header:'Comment',
268
+ align:'center',
269
+ width:60,
270
+ items:[{
271
+ getClass: function(v, meta, rec) { // Or return a class from a function
272
+ this.items[0].tooltip = rec.get('comments');
273
+ return 'info-col';
274
+ },
275
+ handler: function(grid, rowIndex, colIndex) {
276
+ return false;
277
+ }
278
+ }]
279
+ }
280
+ ],
281
+ loadMask: true,
282
+ stripeRows: true,
283
+ store: Ext.create("Ext.data.Store",{
284
+ autoLoad: true,
285
+ proxy:{
286
+ type:'ajax',
287
+ url: '/erp_products/erp_app/desktop/product_manager/prices/'+config.productTypeId,
288
+ reader:{
289
+ root: 'prices',
290
+ type:'json'
291
+ }
292
+ },
293
+ fields:[{
294
+ name:'price',
295
+ type:'decimal'
296
+ }, 'currency', 'currency_display', 'from_date', 'thru_date', 'description','comments','pricing_plan_id']
297
+ })
298
+ });
299
+
300
+ this.addEditPriceBtn = Ext.create("Ext.button.Button",{
301
+ scope:this,
302
+ text:'Add Price',
303
+ handler:function(btn){
304
+ var formPanel = btn.findParentByType('form');
305
+ var basicForm = formPanel.getForm();
306
+
307
+ basicForm.submit({
308
+ reset:true,
309
+ success:function(form, action){
310
+ var obj = Ext.decode(action.response.responseText);
311
+ if(obj.success){
312
+ self.addEditPriceBtn.setText('Add Price');
313
+ self.cancelBtn.hide();
314
+ Ext.getCmp('productListPanel').loadProducts();
315
+ self.pricesGridPanel.getStore().load();
281
316
  }
282
- ],
283
- loadMask: true,
284
- stripeRows: true,
285
- store: Ext.create("Ext.data.Store",{
286
- autoLoad: true,
287
- proxy:{
288
- type:'ajax',
289
- url: '/erp_products/erp_app/desktop/product_manager/prices/'+config.productTypeId,
290
- reader:{
291
- root: 'prices',
292
- type:'json'
293
- }
294
- },
295
- fields:[{
296
- name:'price',
297
- type:'decimal'
298
- }, 'currency', 'currency_display', 'from_date', 'thru_date', 'description','comments','pricing_plan_id']
299
- })
300
- });
301
-
302
- this.addEditPriceBtn = Ext.create("Ext.button.Button",{
303
- scope:this,
304
- text:'Add Price',
305
- handler:function(btn){
306
- var formPanel = btn.findParentByType('form');
307
- var basicForm = formPanel.getForm();
308
-
309
- basicForm.submit({
310
- reset:true,
311
- success:function(form, action){
312
- var obj = Ext.decode(action.response.responseText);
313
- if(obj.success){
314
- self.addEditPriceBtn.setText('Add Price');
315
- self.cancelBtn.hide();
316
- Ext.getCmp('productListPanel').loadProducts();
317
- self.pricesGridPanel.getStore().load();
318
- }
319
- else{
320
- Ext.Msg.alert("Error", 'Error creating price');
321
- }
322
- },
323
- failure:function(form, action){
324
- Ext.Msg.alert("Error", 'Error creating price');
325
- }
326
- });
317
+ else{
318
+ Ext.Msg.alert("Error", 'Error creating price');
327
319
  }
320
+ },
321
+ failure:function(form, action){
322
+ Ext.Msg.alert("Error", 'Error creating price');
323
+ }
328
324
  });
329
-
330
- this.cancelBtn = Ext.create("Ext.button.Button",{
331
- text:'Cancel',
332
- hidden:true,
333
- handler:function(btn){
334
- var formPanel = btn.findParentByType('form');
335
- var basicForm = formPanel.getForm();
336
- basicForm.reset();
337
- self.addEditPriceBtn.setText('Add Price');
338
- self.cancelBtn.hide();
339
- }
340
- });
341
-
342
- this.addPriceFormPanel = Ext.create("Ext.form.Panel",{
325
+ }
326
+ });
327
+
328
+ this.cancelBtn = Ext.create("Ext.button.Button",{
329
+ text:'Cancel',
330
+ hidden:true,
331
+ handler:function(btn){
332
+ var formPanel = btn.findParentByType('form');
333
+ var basicForm = formPanel.getForm();
334
+ basicForm.reset();
335
+ self.addEditPriceBtn.setText('Add Price');
336
+ self.cancelBtn.hide();
337
+ }
338
+ });
339
+
340
+ this.addPriceFormPanel = Ext.create("Ext.form.Panel",{
341
+ layout:'anchor',
342
+ collapsible:true,
343
+ split:true,
344
+ height:175,
345
+ frame:true,
346
+ region:'south',
347
+ buttonAlign:'center',
348
+ bodyStyle:'padding:5px 5px 0',
349
+ url:'/erp_products/erp_app/desktop/product_manager/new_and_update_price',
350
+ items: [
351
+ {
352
+ xtype:'textfield',
353
+ width:400,
354
+ name:'description',
355
+ fieldLabel:'Description'
356
+ },
357
+ {
358
+ layout:'column',
359
+ xtype:'container',
360
+ frame:false,
361
+ border:false,
362
+ defaults:{
363
+ columnWidth:0.25,
364
+ border:false,
365
+ frame:false,
366
+ xtype:'container',
367
+ bodyStyle:'padding:0 18px 0 0'
368
+ },
369
+ items:[{
370
+ items:[
371
+ {
372
+ fieldLabel:'Price',
373
+ xtype:'numberfield',
374
+ width:200,
343
375
  layout:'anchor',
344
- collapsible:true,
345
- split:true,
346
- height:175,
347
- frame:true,
348
- region:'south',
349
- buttonAlign:'center',
350
- bodyStyle:'padding:5px 5px 0',
351
- url:'/erp_products/erp_app/desktop/product_manager/new_and_update_price',
352
- items: [
353
- {
354
- xtype:'textfield',
355
- width:400,
356
- name:'description',
357
- fieldLabel:'Description'
358
- },
359
- {
360
- layout:'column',
361
- xtype:'container',
362
- frame:false,
363
- border:false,
364
- defaults:{
365
- columnWidth:0.25,
366
- border:false,
367
- frame:false,
368
- xtype:'container',
369
- bodyStyle:'padding:0 18px 0 0'
370
- },
371
- items:[{
372
- items:[
373
- {
374
- fieldLabel:'Price',
375
- xtype:'numberfield',
376
- width:200,
377
- layout:'anchor',
378
- allowBlank:false,
379
- name:'price'
380
- }
381
- ]
382
- },
383
- {
384
- items:[
385
- {
386
- fieldLabel:'Currency',
387
- xtype:'combo',
388
- width:200,
389
- id : 'call_center_party_country',
390
- allowBlank : false,
391
- store :Ext.create("Ext.data.Store",{
392
- autoLoad: true,
393
- proxy:{
394
- type:'ajax',
395
- url: '/erp_products/erp_app/desktop/product_manager/currencies',
396
- reader:{
397
- root: 'currencies',
398
- type:'json'
399
- }
400
- },
401
- fields: [
402
- {
403
- name:'internal_identifier'
404
- },
405
- {
406
- name:'id'
407
- }
408
- ]
409
- }),
410
- hiddenName: 'currency',
411
- hiddenField: 'currency',
412
- valueField: 'id',
413
- displayField: 'internal_identifier',
414
- forceSelection : true,
415
- triggerAction : 'all',
416
- name:'currency'
417
- }
418
- ]
419
- },
420
- {
421
- items:[
422
- {
423
- fieldLabel:'From Date',
424
- xtype:'datefield',
425
- width:200,
426
- allowBlank:false,
427
- name:'from_date'
428
- }
429
- ]
430
- },
431
- {
432
- items:[
433
- {
434
- fieldLabel:'Thru Date',
435
- xtype:'datefield',
436
- width:200,
437
- allowBlank:false,
438
- name:'thru_date'
439
- }
440
- ]
441
- }]
442
- },
443
- {
444
- xtype:'textarea',
445
- height:50,
446
- width:400,
447
- name:'comments',
448
- fieldLabel:'Comments'
449
- },
450
- {
451
- xtype:'hidden',
452
- name:'product_type_id',
453
- value:config.productTypeId
454
- },
455
- {
456
- xtype:'hidden',
457
- name:'pricing_plan_id'
458
- }
459
- ],
460
- buttons:[
461
- this.addEditPriceBtn,
462
- this.cancelBtn
463
- ]
464
- });
465
-
466
- config = Ext.apply({
467
- title:'Pricing',
468
- layout:'border',
469
- items:[this.pricesGridPanel,this.addPriceFormPanel]
470
- }, config);
471
-
472
- Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel.superclass.constructor.call(this, config);
473
- }
376
+ allowBlank:false,
377
+ name:'price'
378
+ }
379
+ ]
380
+ },
381
+ {
382
+ items:[
383
+ {
384
+ fieldLabel:'Currency',
385
+ xtype:'combo',
386
+ width:200,
387
+ id : 'call_center_party_country',
388
+ allowBlank : false,
389
+ store :Ext.create("Ext.data.Store",{
390
+ autoLoad: true,
391
+ proxy:{
392
+ type:'ajax',
393
+ url: '/erp_products/erp_app/desktop/product_manager/currencies',
394
+ reader:{
395
+ root: 'currencies',
396
+ type:'json'
397
+ }
398
+ },
399
+ fields: [
400
+ {
401
+ name:'internal_identifier'
402
+ },
403
+ {
404
+ name:'id'
405
+ }
406
+ ]
407
+ }),
408
+ hiddenName: 'currency',
409
+ hiddenField: 'currency',
410
+ valueField: 'id',
411
+ displayField: 'internal_identifier',
412
+ forceSelection : true,
413
+ triggerAction : 'all',
414
+ name:'currency'
415
+ }
416
+ ]
417
+ },
418
+ {
419
+ items:[
420
+ {
421
+ fieldLabel:'From Date',
422
+ xtype:'datefield',
423
+ width:200,
424
+ allowBlank:false,
425
+ name:'from_date'
426
+ }
427
+ ]
428
+ },
429
+ {
430
+ items:[
431
+ {
432
+ fieldLabel:'Thru Date',
433
+ xtype:'datefield',
434
+ width:200,
435
+ allowBlank:false,
436
+ name:'thru_date'
437
+ }
438
+ ]
439
+ }]
440
+ },
441
+ {
442
+ xtype:'textarea',
443
+ height:50,
444
+ width:400,
445
+ name:'comments',
446
+ fieldLabel:'Comments'
447
+ },
448
+ {
449
+ xtype:'hidden',
450
+ name:'product_type_id',
451
+ value:config.productTypeId
452
+ },
453
+ {
454
+ xtype:'hidden',
455
+ name:'pricing_plan_id'
456
+ }
457
+ ],
458
+ buttons:[
459
+ this.addEditPriceBtn,
460
+ this.cancelBtn
461
+ ]
462
+ });
463
+
464
+ config = Ext.apply({
465
+ title:'Pricing',
466
+ layout:'border',
467
+ items:[this.pricesGridPanel,this.addPriceFormPanel]
468
+ }, config);
469
+
470
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel.superclass.constructor.call(this, config);
471
+ }
474
472
  });
475
473
 
476
474
  //
@@ -478,121 +476,120 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPan
478
476
  //
479
477
 
480
478
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductImagesPanel",{
481
- extend:"Ext.panel.Panel",
482
- alias:'widget.productmanager_productimagespanel',
483
- deleteImage : function(id){
484
- var self = this;
485
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this image?', function(btn){
486
- if(btn == 'no'){
487
- return false;
479
+ extend:"Ext.panel.Panel",
480
+ alias:'widget.productmanager_productimagespanel',
481
+ deleteImage : function(id){
482
+ var self = this;
483
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this image?', function(btn){
484
+ if(btn == 'no'){
485
+ return false;
486
+ }
487
+ else
488
+ {
489
+ Ext.Ajax.request({
490
+ url: '/erp_products/erp_app/desktop/product_manager/delete_image/'+id,
491
+ success: function(response) {
492
+ var obj = Ext.decode(response.responseText);
493
+ if(obj.success){
494
+ self.imageAssetsDataView.getStore().load();
488
495
  }
489
- else
490
- {
491
- var conn = new Ext.data.Connection();
492
- conn.request({
493
- url: '/erp_products/erp_app/desktop/product_manager/delete_image/'+id,
494
- success: function(response) {
495
- var obj = Ext.decode(response.responseText);
496
- if(obj.success){
497
- self.imageAssetsDataView.getStore().load();
498
- }
499
- else{
500
- Ext.Msg.alert('Error', 'Error deleting image.');
501
- }
502
- },
503
- failure: function(response) {
504
- Ext.Msg.alert('Error', 'Error deleting image.');
505
- }
506
- });
496
+ else{
497
+ Ext.Msg.alert('Error', 'Error deleting image.');
507
498
  }
499
+ },
500
+ failure: function(response) {
501
+ Ext.Msg.alert('Error', 'Error deleting image.');
502
+ }
508
503
  });
509
- },
510
-
511
- constructor : function(config) {
512
- var self = this;
513
- var productTypeId = config.productTypeId;
514
- var uploadUrl = '/erp_products/erp_app/desktop/product_manager/new_image'
504
+ }
505
+ });
506
+ },
507
+
508
+ constructor : function(config) {
509
+ var self = this;
510
+ var productTypeId = config.productTypeId;
511
+ var uploadUrl = '/erp_products/erp_app/desktop/product_manager/new_image'
515
512
 
516
- this.imageAssetsDataView = Ext.create("Ext.view.View",{
517
- autoDestroy:true,
518
- itemSelector: 'div.thumb-wrap',
519
- style:'overflow:auto',
520
- store: Ext.create("Ext.data.Store",{
521
- autoLoad: true,
522
- proxy:{
523
- type:'ajax',
524
- url: '/erp_products/erp_app/desktop/product_manager/images/'+productTypeId,
525
- reader:{
526
- root: 'images',
527
- type:'json'
528
- }
529
- },
530
- fields:['name', 'url', 'shortName', 'id']
531
- }),
532
- tpl: new Ext.XTemplate(
533
- '<tpl for=".">',
534
- '<div class="thumb-wrap" id="{name}">',
535
- '<div class="thumb"><img src="{url}" class="thumb-img"></div>',
536
- '<span>{shortName}</span></div>',
537
- '</tpl>'
538
- ),
539
- listeners:{
540
- 'itemcontextmenu':function(view, record, htmlitem, index, e, options){
541
- e.stopEvent();
542
- var contextMenu = Ext.create("Ext.menu.Menu",{
543
- items:[
544
- {
545
- text:'Delete',
546
- iconCls:'icon-delete',
547
- handler:function(btn){
548
- self.deleteImage(self.imageAssetsDataView.getStore().getAt(index).get('id'));
549
- }
550
- }
551
- ]
552
- });
553
- contextMenu.showAt(e.xy);
554
- }
513
+ this.imageAssetsDataView = Ext.create("Ext.view.View",{
514
+ autoDestroy:true,
515
+ itemSelector: 'div.thumb-wrap',
516
+ style:'overflow:auto',
517
+ store: Ext.create("Ext.data.Store",{
518
+ autoLoad: true,
519
+ proxy:{
520
+ type:'ajax',
521
+ url: '/erp_products/erp_app/desktop/product_manager/images/'+productTypeId,
522
+ reader:{
523
+ root: 'images',
524
+ type:'json'
525
+ }
526
+ },
527
+ fields:['name', 'url', 'shortName', 'id']
528
+ }),
529
+ tpl: new Ext.XTemplate(
530
+ '<tpl for=".">',
531
+ '<div class="thumb-wrap" id="{name}">',
532
+ '<div class="thumb"><img src="{url}" class="thumb-img"></div>',
533
+ '<span>{shortName}</span></div>',
534
+ '</tpl>'
535
+ ),
536
+ listeners:{
537
+ 'itemcontextmenu':function(view, record, htmlitem, index, e, options){
538
+ e.stopEvent();
539
+ var contextMenu = Ext.create("Ext.menu.Menu",{
540
+ items:[
541
+ {
542
+ text:'Delete',
543
+ iconCls:'icon-delete',
544
+ handler:function(btn){
545
+ self.deleteImage(self.imageAssetsDataView.getStore().getAt(index).get('id'));
546
+ }
555
547
  }
556
- });
557
-
558
- config = Ext.apply({
559
- id:'product-image-assets',
560
- title:'Images',
561
- autoDestroy:true,
562
- margins: '5 5 5 0',
563
- autoHeight:true,
564
- layout:'fit',
565
- items:[this.imageAssetsDataView],
566
- tbar:{
567
- items:[
568
- {
569
- text:'Add Image',
570
- iconCls:'icon-upload',
571
- handler:function(btn){
572
- var uploadWindow = Ext.create("Compass.ErpApp.Shared.UploadWindow",{
573
- standardUploadUrl:uploadUrl,
574
- flashUploadUrl:uploadUrl,
575
- xhrUploadUrl:uploadUrl,
576
- extraPostData:{
577
- product_type_id:productTypeId
578
- },
579
- listeners:{
580
- 'fileuploaded':function(){
581
- var dataView = btn.findParentByType('panel').query('dataview')[0];
582
- dataView.getStore().load();
583
- Ext.getCmp('productListPanel').loadProducts();
584
- }
585
- }
586
- });
587
- uploadWindow.show();
588
- }
548
+ ]
549
+ });
550
+ contextMenu.showAt(e.xy);
551
+ }
552
+ }
553
+ });
554
+
555
+ config = Ext.apply({
556
+ id:'product-image-assets',
557
+ title:'Images',
558
+ autoDestroy:true,
559
+ margins: '5 5 5 0',
560
+ autoHeight:true,
561
+ layout:'fit',
562
+ items:[this.imageAssetsDataView],
563
+ tbar:{
564
+ items:[
565
+ {
566
+ text:'Add Image',
567
+ iconCls:'icon-upload',
568
+ handler:function(btn){
569
+ var uploadWindow = Ext.create("Compass.ErpApp.Shared.UploadWindow",{
570
+ standardUploadUrl:uploadUrl,
571
+ flashUploadUrl:uploadUrl,
572
+ xhrUploadUrl:uploadUrl,
573
+ extraPostData:{
574
+ product_type_id:productTypeId
575
+ },
576
+ listeners:{
577
+ 'fileuploaded':function(){
578
+ var dataView = btn.findParentByType('panel').query('dataview')[0];
579
+ dataView.getStore().load();
580
+ Ext.getCmp('productListPanel').loadProducts();
589
581
  }
590
- ]
591
- }
592
- }, config);
582
+ }
583
+ });
584
+ uploadWindow.show();
585
+ }
586
+ }
587
+ ]
588
+ }
589
+ }, config);
593
590
 
594
- Compass.ErpApp.Desktop.Applications.ProductManager.ProductImagesPanel.superclass.constructor.call(this, config);
595
- }
591
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductImagesPanel.superclass.constructor.call(this, config);
592
+ }
596
593
  });
597
594
 
598
595
  //
@@ -600,66 +597,66 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductImagesPane
600
597
  //
601
598
 
602
599
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel",{
603
- extend:"Ext.form.Panel",
604
- alias:'widget.productmanager_inventoryformpanel',
605
- initComponent: function() {
606
- Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel.superclass.initComponent.call(this, arguments);
607
- },
608
-
609
- constructor : function(config) {
610
- config = Ext.apply({
611
- title:'Inventory',
612
- frame:true,
613
- buttonAlign:'left',
614
- bodyStyle:'padding:5px 5px 0',
615
- url:'/erp_products/erp_app/desktop/product_manager/update_inventory',
616
- items:[
617
- {
618
- fieldLabel:'SKU #',
619
- xtype:'textfield',
620
- allowBlank:true,
621
- name:'sku'
622
- },{
623
- fieldLabel:'# Available',
624
- xtype:'numberfield',
625
- allowBlank:false,
626
- name:'number_available'
600
+ extend:"Ext.form.Panel",
601
+ alias:'widget.productmanager_inventoryformpanel',
602
+ initComponent: function() {
603
+ Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel.superclass.initComponent.call(this, arguments);
604
+ },
605
+
606
+ constructor : function(config) {
607
+ config = Ext.apply({
608
+ title:'Inventory',
609
+ frame:true,
610
+ buttonAlign:'left',
611
+ bodyStyle:'padding:5px 5px 0',
612
+ url:'/erp_products/erp_app/desktop/product_manager/update_inventory',
613
+ items:[
614
+ {
615
+ fieldLabel:'SKU #',
616
+ xtype:'textfield',
617
+ allowBlank:true,
618
+ name:'sku'
619
+ },{
620
+ fieldLabel:'# Available',
621
+ xtype:'numberfield',
622
+ allowBlank:false,
623
+ name:'number_available'
624
+ },
625
+ {
626
+ xtype:'hidden',
627
+ name:'product_type_id',
628
+ value:config.productTypeId
629
+ },
630
+ ],
631
+ buttons:[
632
+ {
633
+ text:'Update',
634
+ handler:function(btn){
635
+ var formPanel = btn.findParentByType('form');
636
+ var basicForm = formPanel.getForm();
637
+
638
+ basicForm.submit({
639
+ reset:false,
640
+ success:function(form, action){
641
+ var obj = Ext.decode(action.response.responseText);
642
+ if(obj.success){
643
+ Ext.getCmp('productListPanel').loadProducts();
644
+ }
645
+ else{
646
+ Ext.Msg.alert("Error", 'Error creating price');
647
+ }
627
648
  },
628
- {
629
- xtype:'hidden',
630
- name:'product_type_id',
631
- value:config.productTypeId
632
- },
633
- ],
634
- buttons:[
635
- {
636
- text:'Update',
637
- handler:function(btn){
638
- var formPanel = btn.findParentByType('form');
639
- var basicForm = formPanel.getForm();
640
-
641
- basicForm.submit({
642
- reset:false,
643
- success:function(form, action){
644
- var obj = Ext.decode(action.response.responseText);
645
- if(obj.success){
646
- Ext.getCmp('productListPanel').loadProducts();
647
- }
648
- else{
649
- Ext.Msg.alert("Error", 'Error creating price');
650
- }
651
- },
652
- failure:function(form, action){
653
- Ext.Msg.alert("Error", 'Error creating price');
654
- }
655
- });
656
- }
649
+ failure:function(form, action){
650
+ Ext.Msg.alert("Error", 'Error creating price');
657
651
  }
658
- ]
659
- }, config);
652
+ });
653
+ }
654
+ }
655
+ ]
656
+ }, config);
660
657
 
661
- Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel.superclass.constructor.call(this, config);
662
- }
658
+ Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel.superclass.constructor.call(this, config);
659
+ }
663
660
  });
664
661
 
665
662
  //
@@ -667,39 +664,39 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPane
667
664
  //
668
665
 
669
666
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow",{
670
- extend:"Ext.window.Window",
671
- alias:'widget.productmanager_addproductwindow',
672
- initComponent: function() {
673
- Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow.superclass.initComponent.call(this, arguments);
674
- },
675
-
676
- constructor : function(config) {
677
- var self = this;
678
- config = Ext.apply({
679
- title:'Add New Product',
680
- width:800,
681
- layout:'fit',
682
- height:525,
683
- autoScroll:true,
684
- buttonAlign:'center',
685
- items:{
686
- xtype:'productmanager_productdescriptionform',
687
- url:'/erp_products/erp_app/desktop/product_manager/new',
688
- listeners:{
689
- saved:function(form, newId){
690
- Ext.getCmp('productListPanel').loadProducts();
691
- var win = new Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow({
692
- productTypeId:newId
693
- });
694
- win.show();
695
- self.close();
696
- }
697
- }
698
- }
699
- }, config);
667
+ extend:"Ext.window.Window",
668
+ alias:'widget.productmanager_addproductwindow',
669
+ initComponent: function() {
670
+ Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow.superclass.initComponent.call(this, arguments);
671
+ },
672
+
673
+ constructor : function(config) {
674
+ var self = this;
675
+ config = Ext.apply({
676
+ title:'Add New Product',
677
+ width:800,
678
+ layout:'fit',
679
+ height:600,
680
+ autoScroll:true,
681
+ buttonAlign:'center',
682
+ items:{
683
+ xtype:'productmanager_productdescriptionform',
684
+ url:'/erp_products/erp_app/desktop/product_manager/new',
685
+ listeners:{
686
+ saved:function(form, newId){
687
+ Ext.getCmp('productListPanel').loadProducts();
688
+ var win = new Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow({
689
+ productTypeId:newId
690
+ });
691
+ win.show();
692
+ self.close();
693
+ }
694
+ }
695
+ }
696
+ }, config);
700
697
 
701
- Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow.superclass.constructor.call(this, config);
702
- }
698
+ Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow.superclass.constructor.call(this, config);
699
+ }
703
700
  });
704
701
 
705
702
  //
@@ -707,93 +704,91 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow"
707
704
  //
708
705
 
709
706
  Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow",{
710
- extend:"Ext.window.Window",
711
- alias:'widget.productmanager_updateproductwindow',
712
- initComponent: function() {
713
- Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow.superclass.initComponent.call(this, arguments);
714
- },
715
-
716
- constructor : function(config) {
717
- var self = this;
718
- var activeTab = config['activeTab'] | 0
719
-
720
- var tabLayout = {
721
- xtype:'tabpanel',
722
- items:[
723
- {
724
- title:'Description',
725
- xtype:'productmanager_productdescriptionform',
726
- url:'/erp_products/erp_app/desktop/product_manager/update/'+config.productTypeId,
727
- productTypeId:config.productTypeId,
728
- listeners:{
729
- 'saved':function(form){
730
- Ext.getCmp('productListPanel').loadProducts();
731
- },
732
- 'activate':function(panel){
733
- if(!Compass.ErpApp.Utility.isBlank(panel.initialConfig['productTypeId'])){
734
- var self = this;
735
- var conn = new Ext.data.Connection();
736
- conn.request({
737
- url: '/erp_products/erp_app/desktop/product_manager/show/'+panel.initialConfig['productTypeId'],
738
- success: function(response) {
739
- var obj = Ext.decode(response.responseText);
740
- self.getForm().setValues(obj);
741
- self.query('ckeditor')[0].setValue(obj.description);
742
- },
743
- failure: function(response) {
744
- Ext.Msg.alert('Error', 'Error loading product details.');
745
- }
746
- });
747
- }
748
- }
749
-
750
- }
751
- },
752
- {
753
- xtype:'productmanager_productimagespanel',
754
- productTypeId:config.productTypeId
755
- },
756
- {
757
- xtype:'productmanager_productpricingpanel',
758
- productTypeId:config.productTypeId
759
- },
760
- {
761
- xtype:'productmanager_inventoryformpanel',
762
- productTypeId:config.productTypeId,
763
- listeners:{
764
- 'activate':function(panel){
765
- var self = this;
766
- var conn = new Ext.data.Connection();
767
- conn.request({
768
- url: '/erp_products/erp_app/desktop/product_manager/inventory/'+panel.initialConfig['productTypeId'],
769
- success: function(response) {
770
- var obj = Ext.decode(response.responseText);
771
- self.getForm().setValues(obj);
772
- },
773
- failure: function(response) {
774
- Ext.Msg.alert('Error', 'Error loading inventory.');
775
- }
776
- });
777
- }
707
+ extend:"Ext.window.Window",
708
+ alias:'widget.productmanager_updateproductwindow',
709
+ initComponent: function() {
710
+ Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow.superclass.initComponent.call(this, arguments);
711
+ },
712
+
713
+ constructor : function(config) {
714
+ var self = this;
715
+ var activeTab = config['activeTab'] | 0
716
+
717
+ var tabLayout = {
718
+ xtype:'tabpanel',
719
+ items:[
720
+ {
721
+ title:'Description',
722
+ xtype:'productmanager_productdescriptionform',
723
+ url:'/erp_products/erp_app/desktop/product_manager/update/'+config.productTypeId,
724
+ productTypeId:config.productTypeId,
725
+ listeners:{
726
+ 'saved':function(form){
727
+ Ext.getCmp('productListPanel').loadProducts();
728
+ },
729
+ 'activate':function(panel){
730
+ if(!Compass.ErpApp.Utility.isBlank(panel.initialConfig['productTypeId'])){
731
+ var self = this;
732
+ Ext.Ajax.request({
733
+ url: '/erp_products/erp_app/desktop/product_manager/show/'+panel.initialConfig['productTypeId'],
734
+ success: function(response) {
735
+ var obj = Ext.decode(response.responseText);
736
+ self.getForm().setValues(obj);
737
+ self.query('ckeditor')[0].setValue(obj.description);
738
+ },
739
+ failure: function(response) {
740
+ Ext.Msg.alert('Error', 'Error loading product details.');
778
741
  }
742
+ });
779
743
  }
780
- ]
744
+ }
745
+
781
746
  }
747
+ },
748
+ {
749
+ xtype:'productmanager_productimagespanel',
750
+ productTypeId:config.productTypeId
751
+ },
752
+ {
753
+ xtype:'productmanager_productpricingpanel',
754
+ productTypeId:config.productTypeId
755
+ },
756
+ {
757
+ xtype:'productmanager_inventoryformpanel',
758
+ productTypeId:config.productTypeId,
759
+ listeners:{
760
+ 'activate':function(panel){
761
+ var self = this;
762
+ Ext.Ajax.request({
763
+ url: '/erp_products/erp_app/desktop/product_manager/inventory/'+panel.initialConfig['productTypeId'],
764
+ success: function(response) {
765
+ var obj = Ext.decode(response.responseText);
766
+ self.getForm().setValues(obj);
767
+ },
768
+ failure: function(response) {
769
+ Ext.Msg.alert('Error', 'Error loading inventory.');
770
+ }
771
+ });
772
+ }
773
+ }
774
+ }
775
+ ]
776
+ }
782
777
 
783
- config = Ext.apply({
784
- title:'Update Product',
785
- width:860,
786
- layout:'fit',
787
- height:560,
788
- autoScroll:true,
789
- items:[tabLayout],
790
- listeners:{
791
- show:function(comp){
792
- comp.query('tabpanel')[0].setActiveTab(activeTab);
793
- }
794
- }
795
- }, config);
778
+ config = Ext.apply({
779
+ title:'Update Product',
780
+ width:860,
781
+ layout:'fit',
782
+ height:620,
783
+ autoScroll:true,
784
+ items:[tabLayout],
785
+ listeners:{
786
+ show:function(comp){
787
+ comp.query('tabpanel')[0].setActiveTab(activeTab);
788
+ }
789
+ }
790
+ }, config);
796
791
 
797
- Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow.superclass.constructor.call(this, config);
798
- }
792
+ Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow.superclass.constructor.call(this, config);
793
+ }
799
794
  });