erp_products 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/GPL-3-LICENSE +674 -0
  2. data/README.rdoc +2 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/erp_products/application.js +9 -0
  5. data/app/assets/stylesheets/erp_products/application.css +7 -0
  6. data/app/controllers/erp_products/erp_app/desktop/product_manager/base_controller.rb +233 -0
  7. data/app/helpers/erp_products/application_helper.rb +4 -0
  8. data/app/models/prod_availability_status_type.rb +5 -0
  9. data/app/models/prod_instance_reln.rb +14 -0
  10. data/app/models/prod_instance_reln_type.rb +4 -0
  11. data/app/models/prod_instance_role_type.rb +4 -0
  12. data/app/models/prod_type_reln.rb +15 -0
  13. data/app/models/prod_type_reln_type.rb +4 -0
  14. data/app/models/prod_type_role_type.rb +4 -0
  15. data/app/models/product_instance.rb +21 -0
  16. data/app/models/product_offer.rb +11 -0
  17. data/app/models/product_package.rb +7 -0
  18. data/app/models/product_type.rb +37 -0
  19. data/app/models/simple_product_offer.rb +4 -0
  20. data/app/views/layouts/erp_products/application.html.erb +14 -0
  21. data/config/routes.rb +4 -0
  22. data/db/data_migrations/20110324010232_product_role_types.rb +23 -0
  23. data/db/data_migrations/20110527160807_add_default_prod_avail_types.rb +26 -0
  24. data/db/data_migrations/20110728201730_create_desktop_app_product_manager.rb +25 -0
  25. data/db/migrate/20080805000040_base_products.rb +232 -0
  26. data/db/migrate/20080805000041_base_products_indexes.rb +58 -0
  27. data/lib/erp_products/engine.rb +16 -0
  28. data/lib/erp_products/extensions/active_record/acts_as_product_instance.rb +50 -0
  29. data/lib/erp_products/extensions/active_record/acts_as_product_offer.rb +52 -0
  30. data/lib/erp_products/extensions/active_record/acts_as_product_type.rb +59 -0
  31. data/lib/erp_products/extensions.rb +3 -0
  32. data/lib/erp_products/version.rb +3 -0
  33. data/lib/erp_products.rb +5 -0
  34. data/lib/tasks/erp_products_tasks.rake +4 -0
  35. data/public/javascripts/erp_app/desktop/applications/product_manager/module.js +799 -0
  36. data/public/javascripts/erp_app/desktop/applications/product_manager/product_list_panel.js +141 -0
  37. data/public/stylesheets/erp_app/desktop/applications/product_manager/style.css +71 -0
  38. metadata +119 -0
@@ -0,0 +1,799 @@
1
+ Ext.ns("Compass.ErpApp.Desktop.Applications");
2
+
3
+ //
4
+ //module
5
+ //
6
+
7
+ 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();
38
+ }
39
+ });
40
+
41
+ //
42
+ //form to manage description and title
43
+ //
44
+
45
+ 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);
50
+
51
+ this.addEvents(
52
+ /**
53
+ * @event saved
54
+ * Fired after form is saved.
55
+ * @param {Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm} form this object
56
+ * @param {integer} Newly create id
57
+ */
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
+ }
104
+ },
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
+ }
136
+ }
137
+ ]
138
+ }, config);
139
+
140
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductDescriptionForm.superclass.constructor.call(this, config);
141
+ }
142
+ });
143
+
144
+ //
145
+ //form to manage pricing
146
+ //
147
+
148
+ 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;
162
+ }
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
+ });
182
+ }
183
+ });
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
+ }]
281
+ }
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
+ });
327
+ }
328
+ });
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",{
343
+ 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
+ }
474
+ });
475
+
476
+ //
477
+ //Panel for product images
478
+ //
479
+
480
+ 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;
488
+ }
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
+ });
507
+ }
508
+ });
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'
515
+
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
+ }
555
+ }
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
+ }
589
+ }
590
+ ]
591
+ }
592
+ }, config);
593
+
594
+ Compass.ErpApp.Desktop.Applications.ProductManager.ProductImagesPanel.superclass.constructor.call(this, config);
595
+ }
596
+ });
597
+
598
+ //
599
+ //Inventory Management
600
+ //
601
+
602
+ 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'
627
+ },
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
+ }
657
+ }
658
+ ]
659
+ }, config);
660
+
661
+ Compass.ErpApp.Desktop.Applications.ProductManager.InventoryFormPanel.superclass.constructor.call(this, config);
662
+ }
663
+ });
664
+
665
+ //
666
+ //Add product window
667
+ //
668
+
669
+ 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);
700
+
701
+ Compass.ErpApp.Desktop.Applications.ProductManager.AddProductWindow.superclass.constructor.call(this, config);
702
+ }
703
+ });
704
+
705
+ //
706
+ //Update product window
707
+ //
708
+
709
+ 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
+ }
778
+ }
779
+ }
780
+ ]
781
+ }
782
+
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);
796
+
797
+ Compass.ErpApp.Desktop.Applications.ProductManager.UpdateProductWindow.superclass.constructor.call(this, config);
798
+ }
799
+ });