erp_commerce 3.1.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4e6b6692526e51decb1e65fe0e0c8f144722105
4
+ data.tar.gz: 6c0d00362d5a6c460588775a8fe18eb22bc5ddc6
5
+ SHA512:
6
+ metadata.gz: d3289c22d87a6549677659a617b9f36777700c2510f2996453e3748f3db53a2fcd9f24a808842b8fe2181bc7531df340a57bc94db6c6f1d92ebd6caa44202041
7
+ data.tar.gz: bb1b935e104f9979aa6fc8b8729e4009f62d35b69e12340810af4354548392302e2b1e1f52c55cd6a63db9407fd44c8a8865bde77bb454c8c87397d5e9677eb4
@@ -3,52 +3,54 @@ Compass.ErpApp.Widgets.ProductCatalog = {
3
3
  " :action => :index,\n",
4
4
  " :params => {:cart_items_url => '{cartItemsUrl}'} %>"),
5
5
 
6
- add:function(){
7
- var addProductCatalogWidgetWindow = Ext.create("Ext.window.Window",{
8
- layout:'fit',
9
- width:300,
10
- title:'Add Product Catalog Widget',
11
- height:100,
12
- buttonAlign:'center',
13
- items: Ext.create("Ext.form.Panel",{
6
+ add: function () {
7
+ var addProductCatalogWidgetWindow = Ext.create("Ext.window.Window", {
8
+ layout: 'fit',
9
+ width: 300,
10
+ title: 'Add Product Catalog Widget',
11
+ height: 100,
12
+ buttonAlign: 'center',
13
+ items: Ext.create("Ext.form.Panel", {
14
14
  labelWidth: 100,
15
- frame:false,
16
- bodyStyle:'padding:5px 5px 0',
15
+ frame: false,
16
+ bodyStyle: 'padding:5px 5px 0',
17
17
  defaults: {
18
18
  width: 225
19
19
  },
20
20
  items: [
21
- {
22
- xtype:'textfield',
23
- fieldLabel:'Cart Items Url',
24
- name:'cartItemsUrl',
25
- hidden:false,
26
- value:'/cart-items'
27
- }
21
+ {
22
+ xtype: 'textfield',
23
+ fieldLabel: 'Cart Items Url',
24
+ name: 'cartItemsUrl',
25
+ hidden: false,
26
+ value: '/cart-items'
27
+ }
28
28
  ]
29
29
  }),
30
- buttons: [{
31
- text:'Submit',
32
- handler:function(button){
33
- var window = button.findParentByType('window');
34
- var formPanel = window.query('form')[0];
35
- var basicForm = formPanel.getForm();
36
- var cartItemsUrl = basicForm.findField('cartItemsUrl').getValue();
37
- var data = {
38
- cartItemsUrl:cartItemsUrl
39
- };
30
+ buttons: [
31
+ {
32
+ text: 'Submit',
33
+ handler: function (button) {
34
+ var window = button.findParentByType('window');
35
+ var formPanel = window.query('form')[0];
36
+ var basicForm = formPanel.getForm();
37
+ var cartItemsUrl = basicForm.findField('cartItemsUrl').getValue();
38
+ var data = {
39
+ cartItemsUrl: cartItemsUrl
40
+ };
40
41
 
41
- //add rendered template to center region editor
42
- Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(Compass.ErpApp.Widgets.ProductCatalog.template.apply(data));
43
- addProductCatalogWidgetWindow.close();
44
- }
45
- },
46
- {
47
- text: 'Close',
48
- handler: function(){
49
- addProductCatalogWidgetWindow.close();
42
+ //add rendered template to center region editor
43
+ Ext.getCmp('knitkitCenterRegion').addContentToActiveCodeMirror(Compass.ErpApp.Widgets.ProductCatalog.template.apply(data));
44
+ addProductCatalogWidgetWindow.close();
45
+ }
46
+ },
47
+ {
48
+ text: 'Close',
49
+ handler: function () {
50
+ addProductCatalogWidgetWindow.close();
51
+ }
50
52
  }
51
- }]
53
+ ]
52
54
 
53
55
  });
54
56
  addProductCatalogWidgetWindow.show();
@@ -56,7 +58,7 @@ Compass.ErpApp.Widgets.ProductCatalog = {
56
58
  }
57
59
 
58
60
  Compass.ErpApp.Widgets.AvailableWidgets.push({
59
- name:'Product Catalog',
60
- iconUrl:'/images/icons/product/product_48x48.png',
61
- onClick:Compass.ErpApp.Widgets.ProductCatalog.add
61
+ name: 'Product Catalog',
62
+ iconUrl: '/images/icons/product/product_48x48.png',
63
+ onClick: Compass.ErpApp.Widgets.ProductCatalog.add
62
64
  });
@@ -101,10 +101,10 @@ Compass.ErpApp.Widgets.ShoppingCart = {
101
101
  });
102
102
  addShoppingCartWidget.show();
103
103
  }
104
- }
104
+ };
105
105
 
106
106
  Compass.ErpApp.Widgets.AvailableWidgets.push({
107
107
  name: 'Shopping Cart',
108
- iconUrl: '/images/icons/shoppingcart/shoppingcart_48x48.png',
108
+ iconUrl: '/images/icons/shopping_cart/shopping_cart_48x48.png',
109
109
  onClick: Compass.ErpApp.Widgets.ShoppingCart.addShoppingCart
110
110
  });
@@ -0,0 +1,66 @@
1
+ require 'active_merchant'
2
+ require 'yaml'
3
+
4
+ module ErpCommerce
5
+ module ActiveMerchantWrappers
6
+ class AuthorizeNetWrapper
7
+
8
+ def self.purchase(credit_card, amount, cvv, gateway_options={})
9
+ result = {}
10
+
11
+ login_information = YAML.load_file(File.join(Rails.root, 'config/authorize_net.yml')).symbolize_keys
12
+
13
+ #setup gateway
14
+ gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(login_information)
15
+
16
+ #set credit card info
17
+ credit_card_result = ActiveMerchant::Billing::CreditCard.new({
18
+ :first_name => credit_card.first_name_on_card,
19
+ :last_name => credit_card.last_name_on_card,
20
+ :number => credit_card.private_card_number,
21
+ :month => credit_card.expiration_month,
22
+ :year => credit_card.expiration_year,
23
+ :verification_value => cvv,
24
+ :brand => ErpCommerce::ActiveMerchantWrappers::CreditCardValidation.get_card_type(credit_card.private_card_number)
25
+ })
26
+
27
+ if credit_card_result.valid?
28
+ cents = (amount.to_d * 100)
29
+ response = gateway.purchase(cents, credit_card_result, gateway_options)
30
+
31
+ if response.success?
32
+ result[:message] = response.message
33
+ result[:payment] = Payment.new
34
+ result[:payment].authorization_code = response.authorization
35
+ result[:payment].success = true
36
+ result[:payment].purchase
37
+ else
38
+ result[:message] = response.message
39
+ result[:payment] = Payment.new
40
+ result[:payment].success = false
41
+ result[:payment].decline
42
+ end
43
+
44
+ gateway = PaymentGateway.create(
45
+ :response => response.message,
46
+ :payment_gateway_action => PaymentGatewayAction.find_by_internal_identifier('authorize')
47
+ )
48
+
49
+ result[:payment].payment_gateways << gateway
50
+ result[:payment].save
51
+ else
52
+ result[:message] = "<ul>"
53
+ credit_card_result.errors.full_messages.each do |current_notice_msg|
54
+ result[:message] << "<li>"
55
+ result[:message] << current_notice_msg
56
+ result[:message] << "</li>"
57
+ end
58
+ result[:message] << "<ul>"
59
+ end
60
+
61
+ result
62
+ end
63
+
64
+ end #AuthorizeNetWrapper
65
+ end #ActiveMerchantWrapper
66
+ end #ErpCommerce
@@ -1,9 +1,13 @@
1
1
  module ErpCommerce
2
2
  module VERSION #:nodoc:
3
- MAJOR = 3
4
- MINOR = 1
5
- TINY = 4
3
+ MAJOR = 4
4
+ MINOR = 0
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
9
+
10
+ def self.version
11
+ ErpCommerce::VERSION::STRING
12
+ end
9
13
  end
metadata CHANGED
@@ -1,36 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_commerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
5
- prerelease:
4
+ version: 4.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rick Koloski, Russell Holmes
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-27 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
13
12
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: aasm
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - '='
20
- - !ruby/object:Gem::Version
21
- version: 3.0.14
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 3.0.14
30
13
  - !ruby/object:Gem::Dependency
31
14
  name: activemerchant
32
15
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
16
  requirements:
35
17
  - - '='
36
18
  - !ruby/object:Gem::Version
@@ -38,7 +20,6 @@ dependencies:
38
20
  type: :runtime
39
21
  prerelease: false
40
22
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
23
  requirements:
43
24
  - - '='
44
25
  - !ruby/object:Gem::Version
@@ -46,35 +27,31 @@ dependencies:
46
27
  - !ruby/object:Gem::Dependency
47
28
  name: erp_orders
48
29
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
30
  requirements:
51
- - - ~>
31
+ - - "~>"
52
32
  - !ruby/object:Gem::Version
53
- version: '3.1'
33
+ version: '4.0'
54
34
  type: :runtime
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
37
  requirements:
59
- - - ~>
38
+ - - "~>"
60
39
  - !ruby/object:Gem::Version
61
- version: '3.1'
40
+ version: '4.0'
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: erp_dev_svcs
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ~>
45
+ - - "~>"
68
46
  - !ruby/object:Gem::Version
69
- version: '3.1'
47
+ version: '4.0'
70
48
  type: :development
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ~>
52
+ - - "~>"
76
53
  - !ruby/object:Gem::Version
77
- version: '3.1'
54
+ version: '4.0'
78
55
  description: The CompassAE Commerce Engine uses the engines that implement Parties,
79
56
  Products and Orders, and adds the ability to conduct commerce. It implements a pricing
80
57
  engine, fees, payment gateways.
@@ -84,10 +61,9 @@ executables: []
84
61
  extensions: []
85
62
  extra_rdoc_files: []
86
63
  files:
87
- - app/assets/javascripts/erp_commerce/application.js
88
- - app/assets/stylesheets/erp_commerce/application.css
89
- - app/controllers/erp_commerce/application_controller.rb
90
- - app/helpers/erp_commerce/application_helper.rb
64
+ - GPL-3-LICENSE
65
+ - README.md
66
+ - Rakefile
91
67
  - app/mailers/checkout_mailer.rb
92
68
  - app/models/accepted_credit_card.rb
93
69
  - app/models/bank_account.rb
@@ -118,7 +94,6 @@ files:
118
94
  - app/models/pricing_plan_component.rb
119
95
  - app/models/valid_price_plan_component.rb
120
96
  - app/views/checkout_mailer/email_confirmation.html.erb
121
- - app/views/layouts/erp_commerce/application.html.erb
122
97
  - app/widgets/orders/base.rb
123
98
  - app/widgets/orders/javascript/orders.js
124
99
  - app/widgets/orders/views/index.html.erb
@@ -139,28 +114,26 @@ files:
139
114
  - db/data_migrations/20101011152441_payment_gateway_actions.rb
140
115
  - db/data_migrations/20130408200643_add_credit_card_biz_txn_acct_types.rb
141
116
  - db/migrate/20100823174238_erp_commerce_base.rb
117
+ - lib/erp_commerce.rb
118
+ - lib/erp_commerce/active_merchant_wrappers.rb
119
+ - lib/erp_commerce/active_merchant_wrappers/authorize_net_wrapper.rb
142
120
  - lib/erp_commerce/active_merchant_wrappers/brain_tree_gateway_wrapper.rb
143
121
  - lib/erp_commerce/active_merchant_wrappers/credit_card_validation.rb
144
- - lib/erp_commerce/active_merchant_wrappers.rb
145
122
  - lib/erp_commerce/config.rb
146
123
  - lib/erp_commerce/engine.rb
124
+ - lib/erp_commerce/extensions.rb
147
125
  - lib/erp_commerce/extensions/active_record/acts_as_fee.rb
148
126
  - lib/erp_commerce/extensions/active_record/acts_as_priceable.rb
149
- - lib/erp_commerce/extensions/compass_ae/erp_products/erp_app/desktop/product_manager/base_controller.rb
150
- - lib/erp_commerce/extensions.rb
151
127
  - lib/erp_commerce/order_helper.rb
152
128
  - lib/erp_commerce/version.rb
153
- - lib/erp_commerce.rb
154
129
  - lib/tasks/erp_commerce_tasks.rake
155
- - public/javascripts/extensions/compass_ae/erp_app/desktop/applications/product_manager/product_pricing_panel.js
156
- - GPL-3-LICENSE
157
- - Rakefile
158
- - README.md
130
+ - spec/dummy/Rakefile
159
131
  - spec/dummy/app/assets/javascripts/application.js
160
132
  - spec/dummy/app/assets/stylesheets/application.css
161
133
  - spec/dummy/app/controllers/application_controller.rb
162
134
  - spec/dummy/app/helpers/application_helper.rb
163
135
  - spec/dummy/app/views/layouts/application.html.erb
136
+ - spec/dummy/config.ru
164
137
  - spec/dummy/config/application.rb
165
138
  - spec/dummy/config/boot.rb
166
139
  - spec/dummy/config/database.yml
@@ -174,12 +147,10 @@ files:
174
147
  - spec/dummy/config/initializers/wrap_parameters.rb
175
148
  - spec/dummy/config/locales/en.yml
176
149
  - spec/dummy/config/routes.rb
177
- - spec/dummy/config.ru
178
150
  - spec/dummy/public/404.html
179
151
  - spec/dummy/public/422.html
180
152
  - spec/dummy/public/500.html
181
153
  - spec/dummy/public/favicon.ico
182
- - spec/dummy/Rakefile
183
154
  - spec/dummy/script/rails
184
155
  - spec/factories/basic.rb
185
156
  - spec/models/credit_card_account_party_role_spec.rb
@@ -202,27 +173,26 @@ files:
202
173
  homepage: http://development.compassagile.com
203
174
  licenses:
204
175
  - GPL-3
176
+ metadata: {}
205
177
  post_install_message:
206
178
  rdoc_options: []
207
179
  require_paths:
208
180
  - lib
209
181
  required_ruby_version: !ruby/object:Gem::Requirement
210
- none: false
211
182
  requirements:
212
- - - ! '>='
183
+ - - ">="
213
184
  - !ruby/object:Gem::Version
214
185
  version: '0'
215
186
  required_rubygems_version: !ruby/object:Gem::Requirement
216
- none: false
217
187
  requirements:
218
- - - ! '>='
188
+ - - ">="
219
189
  - !ruby/object:Gem::Version
220
190
  version: '0'
221
191
  requirements: []
222
192
  rubyforge_project:
223
- rubygems_version: 1.8.25
193
+ rubygems_version: 2.2.2
224
194
  signing_key:
225
- specification_version: 3
195
+ specification_version: 4
226
196
  summary: The CompassAE Commerce Engine uses the engines that implement Parties, Products
227
197
  and Orders, and adds the ability to conduct commerce.
228
198
  test_files:
@@ -1,9 +0,0 @@
1
- // This is a manifest file that'll be compiled into including all the files listed below.
2
- // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
- // be included in the compiled file accessible from http://example.com/assets/application.js
4
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
- // the compiled file.
6
- //
7
- //= require jquery
8
- //= require jquery_ujs
9
- //= require_tree .
@@ -1,7 +0,0 @@
1
- /*
2
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
- * the top of the compiled file, but it's generally better to create a new file per style scope.
5
- *= require_self
6
- *= require_tree .
7
- */
@@ -1,4 +0,0 @@
1
- module ErpCommerce
2
- class ApplicationController < ActionController::Base
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module ErpCommerce
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>ErpCommerce</title>
5
- <%= stylesheet_link_tag "erp_commerce/application" %>
6
- <%= javascript_include_tag "erp_commerce/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,83 +0,0 @@
1
- ErpProducts::ErpApp::Desktop::ProductManager::BaseController.class_eval do
2
-
3
- #
4
- #Prices
5
- #
6
-
7
- def currencies
8
- Currency.include_root_in_json = false
9
- render :inline => "{currencies:#{Currency.all.to_json(:only => [:id, :internal_identifier])}}"
10
- end
11
-
12
- def prices
13
- result = {:prices => []}
14
-
15
- product_type = ProductType.find(params[:id])
16
- product_type.pricing_plans.each do |pricing_plan|
17
- result[:prices] << {
18
- :pricing_plan_id => pricing_plan.id,
19
- :price => pricing_plan.money_amount,
20
- :currency => pricing_plan.currency.id,
21
- :currency_display => pricing_plan.currency.internal_identifier,
22
- :from_date => pricing_plan.from_date,
23
- :thru_date => pricing_plan.thru_date,
24
- :description => pricing_plan.description,
25
- :comments => pricing_plan.comments
26
- }
27
- end
28
-
29
- render :json => result
30
- end
31
-
32
-
33
- #pricing uses one form for new models and updates. So we use one action
34
- def new_and_update_price
35
- result = {}
36
-
37
- if params[:pricing_plan_id].blank?
38
- pricing_plan = PricingPlan.new(
39
- :money_amount => params[:price],
40
- :comments => params[:comments],
41
- :currency => Currency.find(params[:currency]),
42
- :from_date => Date.strptime(params[:from_date], '%m/%d/%Y').to_date,
43
- :thru_date => Date.strptime(params[:thru_date], '%m/%d/%Y').to_date,
44
- :description => params[:description],
45
- :is_simple_amount => true
46
- )
47
-
48
- if pricing_plan.save
49
- product_type = ProductType.find(params[:product_type_id])
50
- product_type.pricing_plans << pricing_plan
51
- if product_type.save
52
- result[:success] = true
53
- else
54
- pricing_plan.destroy
55
- result[:success] = false
56
- end
57
- else
58
- result[:success] = false
59
- end
60
- else
61
- pricing_plan = PricingPlan.find(params[:pricing_plan_id])
62
- pricing_plan.money_amount = params[:price]
63
- pricing_plan.currency = Currency.find(params[:currency])
64
- pricing_plan.from_date = Date.strptime(params[:from_date], '%m/%d/%Y').to_date
65
- pricing_plan.thru_date = Date.strptime(params[:thru_date], '%m/%d/%Y').to_date
66
- pricing_plan.description = params[:description]
67
- pricing_plan.comments = params[:comments]
68
-
69
- if pricing_plan.save
70
- result[:success] = true
71
- else
72
- result[:success] = false
73
- end
74
- end
75
-
76
- render :json => result
77
- end
78
-
79
- def delete_price
80
- render :json => (PricingPlan.find(params[:id]).destroy) ? {:success => true} : {:success => false}
81
- end
82
-
83
- end
@@ -1,329 +0,0 @@
1
- //
2
- //form to manage pricing
3
- //
4
-
5
- Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductPricingPanel",{
6
- extend:"Ext.panel.Panel",
7
- alias:'widget.productmanager_productpricingpanel',
8
- updatePrice : function(rec){
9
- this.addEditPriceBtn.setText('Update Price');
10
- this.cancelBtn.show();
11
- this.addPriceFormPanel.getForm().setValues(rec.data);
12
- },
13
-
14
- deletePrice : function(rec){
15
- var self = this;
16
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this price?', function(btn){
17
- if(btn == 'no'){
18
- return false;
19
- }
20
- else
21
- {
22
- Ext.Ajax.request({
23
- url: '/erp_products/erp_app/desktop/product_manager/delete_price/'+rec.get('pricing_plan_id'),
24
- success: function(response) {
25
- var obj = Ext.decode(response.responseText);
26
- if(obj.success){
27
- Ext.getCmp('productListPanel').loadProducts();
28
- self.pricesGridPanel.getStore().load();
29
- }
30
- else{
31
- Ext.Msg.alert('Error', 'Error deleting price.');
32
- }
33
- },
34
- failure: function(response) {
35
- Ext.Msg.alert('Error', 'Error deleting price.');
36
- }
37
- });
38
- }
39
- });
40
- },
41
-
42
- constructor : function(config) {
43
- var self = this;
44
- var productTypeId = Compass.ErpApp.Desktop.Applications.ProductManager.selectedProductTypeId;
45
-
46
- this.pricesGridPanel = Ext.create("Ext.grid.Panel",{
47
- layout:'fit',
48
- region:'center',
49
- split:true,
50
- columns: [
51
- {
52
- header:'Description',
53
- width:310,
54
- sortable: false,
55
- dataIndex: 'description'
56
- },
57
- {
58
- header: 'Price',
59
- width: 75,
60
- sortable: true,
61
- dataIndex: 'price',
62
- renderer:function(v){
63
- return v.toFixed(2);
64
- }
65
- },
66
- {
67
- header: 'Currency',
68
- width: 75,
69
- sortable: true,
70
- dataIndex: 'currency_display'
71
- },
72
- {
73
- header: 'From Date',
74
- width: 90,
75
- sortable: true,
76
- dataIndex: 'from_date',
77
- renderer: Ext.util.Format.dateRenderer('m/d/Y')
78
- },
79
- {
80
- header: 'Thru Date',
81
- width: 90,
82
- sortable: true,
83
- dataIndex: 'thru_date',
84
- renderer: Ext.util.Format.dateRenderer('m/d/Y')
85
- },
86
- {
87
- menuDisabled:true,
88
- resizable:false,
89
- xtype:'actioncolumn',
90
- header:'Update',
91
- align:'center',
92
- width:60,
93
- items:[{
94
- icon:'/images/icons/edit/edit_16x16.png',
95
- tooltip:'Update',
96
- handler :function(grid, rowIndex, colIndex){
97
- var rec = grid.getStore().getAt(rowIndex);
98
- self.updatePrice(rec);
99
- }
100
- }]
101
- },
102
- {
103
- menuDisabled:true,
104
- resizable:false,
105
- xtype:'actioncolumn',
106
- header:'Delete',
107
- align:'center',
108
- width:60,
109
- items:[{
110
- icon:'/images/icons/delete/delete_16x16.png',
111
- tooltip:'Delete',
112
- handler :function(grid, rowIndex, colIndex){
113
- var rec = grid.getStore().getAt(rowIndex);
114
- self.deletePrice(rec);
115
- }
116
- }]
117
- },
118
- {
119
- menuDisabled:true,
120
- resizable:false,
121
- xtype:'actioncolumn',
122
- header:'Comment',
123
- align:'center',
124
- width:60,
125
- items:[{
126
- getClass: function(v, meta, rec) { // Or return a class from a function
127
- this.items[0].tooltip = rec.get('comments');
128
- return 'info-col';
129
- },
130
- handler: function(grid, rowIndex, colIndex) {
131
- return false;
132
- }
133
- }]
134
- }
135
- ],
136
- loadMask: true,
137
- stripeRows: true,
138
- store: Ext.create("Ext.data.Store",{
139
- autoLoad: true,
140
- proxy:{
141
- type:'ajax',
142
- url: '/erp_products/erp_app/desktop/product_manager/prices/'+productTypeId,
143
- reader:{
144
- root: 'prices',
145
- type:'json'
146
- }
147
- },
148
- fields:[{
149
- name:'price',
150
- type:'float'
151
- }, 'currency', 'currency_display', 'from_date', 'thru_date', 'description','comments','pricing_plan_id']
152
- })
153
- });
154
-
155
- this.addEditPriceBtn = Ext.create("Ext.button.Button",{
156
- scope:this,
157
- text:'Add Price',
158
- handler:function(btn){
159
- var formPanel = btn.findParentByType('form');
160
- var basicForm = formPanel.getForm();
161
-
162
- basicForm.submit({
163
- reset:true,
164
- success:function(form, action){
165
- var obj = Ext.decode(action.response.responseText);
166
- if(obj.success){
167
- self.addEditPriceBtn.setText('Add Price');
168
- self.cancelBtn.hide();
169
- Ext.getCmp('productListPanel').loadProducts();
170
- self.pricesGridPanel.getStore().load();
171
- }
172
- else{
173
- Ext.Msg.alert("Error", 'Error creating price');
174
- }
175
- },
176
- failure:function(form, action){
177
- Ext.Msg.alert("Error", 'Error creating price');
178
- }
179
- });
180
- }
181
- });
182
-
183
- this.cancelBtn = Ext.create("Ext.button.Button",{
184
- text:'Cancel',
185
- hidden:true,
186
- handler:function(btn){
187
- var formPanel = btn.findParentByType('form');
188
- var basicForm = formPanel.getForm();
189
- basicForm.reset();
190
- self.addEditPriceBtn.setText('Add Price');
191
- self.cancelBtn.hide();
192
- }
193
- });
194
-
195
- this.addPriceFormPanel = Ext.create("Ext.form.Panel",{
196
- layout:'anchor',
197
- collapsible:true,
198
- split:true,
199
- height:175,
200
- frame:true,
201
- region:'south',
202
- buttonAlign:'center',
203
- bodyStyle:'padding:5px 5px 0',
204
- url:'/erp_products/erp_app/desktop/product_manager/new_and_update_price',
205
- items: [
206
- {
207
- xtype:'textfield',
208
- width:400,
209
- name:'description',
210
- fieldLabel:'Description'
211
- },
212
- {
213
- layout:'column',
214
- xtype:'container',
215
- frame:false,
216
- border:false,
217
- defaults:{
218
- columnWidth:0.25,
219
- border:false,
220
- frame:false,
221
- xtype:'container',
222
- bodyStyle:'padding:0 18px 0 0'
223
- },
224
- items:[{
225
- items:[
226
- {
227
- fieldLabel:'Price',
228
- xtype:'numberfield',
229
- width:200,
230
- layout:'anchor',
231
- allowBlank:false,
232
- name:'price'
233
- }
234
- ]
235
- },
236
- {
237
- items:[
238
- {
239
- fieldLabel:'Currency',
240
- xtype:'combo',
241
- width:200,
242
- id : 'call_center_party_country',
243
- allowBlank : false,
244
- store :Ext.create("Ext.data.Store",{
245
- autoLoad: true,
246
- proxy:{
247
- type:'ajax',
248
- url: '/erp_products/erp_app/desktop/product_manager/currencies',
249
- reader:{
250
- root: 'currencies',
251
- type:'json'
252
- }
253
- },
254
- fields: [
255
- {
256
- name:'internal_identifier'
257
- },
258
- {
259
- name:'id'
260
- }
261
- ]
262
- }),
263
- hiddenName: 'currency',
264
- hiddenField: 'currency',
265
- valueField: 'id',
266
- displayField: 'internal_identifier',
267
- forceSelection : true,
268
- triggerAction : 'all',
269
- name:'currency'
270
- }
271
- ]
272
- },
273
- {
274
- items:[
275
- {
276
- fieldLabel:'From Date',
277
- xtype:'datefield',
278
- width:200,
279
- allowBlank:false,
280
- name:'from_date'
281
- }
282
- ]
283
- },
284
- {
285
- items:[
286
- {
287
- fieldLabel:'Thru Date',
288
- xtype:'datefield',
289
- width:200,
290
- allowBlank:false,
291
- name:'thru_date'
292
- }
293
- ]
294
- }]
295
- },
296
- {
297
- xtype:'textarea',
298
- height:50,
299
- width:400,
300
- name:'comments',
301
- fieldLabel:'Comments'
302
- },
303
- {
304
- xtype:'hidden',
305
- name:'product_type_id',
306
- value:productTypeId
307
- },
308
- {
309
- xtype:'hidden',
310
- name:'pricing_plan_id'
311
- }
312
- ],
313
- buttons:[
314
- this.addEditPriceBtn,
315
- this.cancelBtn
316
- ]
317
- });
318
-
319
- config = Ext.apply({
320
- title:'Pricing',
321
- layout:'border',
322
- items:[this.pricesGridPanel,this.addPriceFormPanel]
323
- }, config);
324
-
325
- this.callParent([config]);
326
- }
327
- });
328
-
329
- Compass.ErpApp.Desktop.Applications.ProductManager.widgets.push({xtype:'productmanager_productpricingpanel'});