camaleon_ecommerce 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/plugins/ecommerce/admin.js +33 -0
  6. data/app/assets/javascripts/plugins/ecommerce/cart.js +207 -0
  7. data/app/assets/javascripts/plugins/ecommerce/fix_form.js +10 -0
  8. data/app/assets/javascripts/plugins/ecommerce/jquery.creditCardValidator.js +208 -0
  9. data/app/assets/stylesheets/plugins/ecommerce/admin.scss +122 -0
  10. data/app/assets/stylesheets/plugins/ecommerce/front.scss +36 -0
  11. data/app/controllers/plugins/ecommerce/admin/coupons_controller.rb +61 -0
  12. data/app/controllers/plugins/ecommerce/admin/orders_controller.rb +96 -0
  13. data/app/controllers/plugins/ecommerce/admin/payment_methods_controller.rb +90 -0
  14. data/app/controllers/plugins/ecommerce/admin/prices_controller.rb +70 -0
  15. data/app/controllers/plugins/ecommerce/admin/settings_controller.rb +22 -0
  16. data/app/controllers/plugins/ecommerce/admin/shipping_methods_controller.rb +62 -0
  17. data/app/controllers/plugins/ecommerce/admin/tax_rates_controller.rb +61 -0
  18. data/app/controllers/plugins/ecommerce/admin_controller.rb +20 -0
  19. data/app/controllers/plugins/ecommerce/front/checkout_controller.rb +166 -0
  20. data/app/controllers/plugins/ecommerce/front/orders_controller.rb +255 -0
  21. data/app/controllers/plugins/ecommerce/front_controller.rb +18 -0
  22. data/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb +46 -0
  23. data/app/helpers/plugins/ecommerce/ecommerce_functions_helper.rb +49 -0
  24. data/app/helpers/plugins/ecommerce/ecommerce_helper.rb +240 -0
  25. data/app/helpers/plugins/ecommerce/ecommerce_payment_helper.rb +67 -0
  26. data/app/models/plugins/ecommerce/cart.rb +40 -0
  27. data/app/models/plugins/ecommerce/coupon.rb +25 -0
  28. data/app/models/plugins/ecommerce/coupon_decorator.rb +60 -0
  29. data/app/models/plugins/ecommerce/order.rb +65 -0
  30. data/app/models/plugins/ecommerce/order_decorator.rb +54 -0
  31. data/app/models/plugins/ecommerce/order_detail.rb +13 -0
  32. data/app/models/plugins/ecommerce/payment_method.rb +29 -0
  33. data/app/models/plugins/ecommerce/product.rb +14 -0
  34. data/app/models/plugins/ecommerce/shipping_method.rb +26 -0
  35. data/app/models/plugins/ecommerce/tax_rate.rb +18 -0
  36. data/app/views/camaleon_cms/html_mailer/order_received.html.erb +3 -0
  37. data/app/views/camaleon_cms/html_mailer/order_received_admin.html.erb +3 -0
  38. data/app/views/camaleon_cms/html_mailer/recovery_cart.html.erb +4 -0
  39. data/app/views/layouts/plugins/ecommerce/mailer.html.erb +22 -0
  40. data/app/views/plugins/ecommerce/admin/coupons/form.html.erb +73 -0
  41. data/app/views/plugins/ecommerce/admin/coupons/index.html.erb +50 -0
  42. data/app/views/plugins/ecommerce/admin/index.html.erb +2 -0
  43. data/app/views/plugins/ecommerce/admin/orders/form.html.erb +64 -0
  44. data/app/views/plugins/ecommerce/admin/orders/index.html.erb +90 -0
  45. data/app/views/plugins/ecommerce/admin/orders/show.html.erb +173 -0
  46. data/app/views/plugins/ecommerce/admin/payment_methods/form.html.erb +115 -0
  47. data/app/views/plugins/ecommerce/admin/payment_methods/index.html.erb +43 -0
  48. data/app/views/plugins/ecommerce/admin/payment_methods/show.html.erb +70 -0
  49. data/app/views/plugins/ecommerce/admin/prices/form.html.erb +49 -0
  50. data/app/views/plugins/ecommerce/admin/prices/index.html.erb +39 -0
  51. data/app/views/plugins/ecommerce/admin/prices/show.html.erb +19 -0
  52. data/app/views/plugins/ecommerce/admin/products/index.html.erb +114 -0
  53. data/app/views/plugins/ecommerce/admin/settings/index.html.erb +25 -0
  54. data/app/views/plugins/ecommerce/admin/shipping_methods/form.html.erb +39 -0
  55. data/app/views/plugins/ecommerce/admin/shipping_methods/index.html.erb +41 -0
  56. data/app/views/plugins/ecommerce/admin/shipping_methods/show.html.erb +22 -0
  57. data/app/views/plugins/ecommerce/admin/tax_rates/form.html.erb +36 -0
  58. data/app/views/plugins/ecommerce/admin/tax_rates/index.html.erb +41 -0
  59. data/app/views/plugins/ecommerce/front/_post_list_item.html.erb +18 -0
  60. data/app/views/plugins/ecommerce/front/checkout/cart_index.html.erb +59 -0
  61. data/app/views/plugins/ecommerce/front/checkout/index.html.erb +166 -0
  62. data/app/views/plugins/ecommerce/front/index.html.erb +2 -0
  63. data/app/views/plugins/ecommerce/front/list_products.html.erb +34 -0
  64. data/app/views/plugins/ecommerce/front/orders/index.html.erb +46 -0
  65. data/app/views/plugins/ecommerce/front/orders/pay_by_bank_transfer.html.erb +67 -0
  66. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card.html.erb +131 -0
  67. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card_authorize_net.erb +150 -0
  68. data/app/views/plugins/ecommerce/front/orders/select_payment.html.erb +70 -0
  69. data/app/views/plugins/ecommerce/front/orders/show.html.erb +76 -0
  70. data/app/views/plugins/ecommerce/front/product.html.erb +105 -0
  71. data/app/views/plugins/ecommerce/layouts/_ecommerce.html.erb +41 -0
  72. data/app/views/plugins/ecommerce/partials/_form_address.html.erb +84 -0
  73. data/app/views/plugins/ecommerce/partials/_table_order_products.html.erb +85 -0
  74. data/config/camaleon_plugin.json +48 -0
  75. data/config/currency.json +154 -0
  76. data/config/currency_en.json +154 -0
  77. data/config/currency_es.json +154 -0
  78. data/config/custom_models.rb +64 -0
  79. data/config/locales/readme.txt +1 -0
  80. data/config/locales/translation.yml +371 -0
  81. data/config/routes.rb +57 -0
  82. data/lib/camaleon_ecommerce.rb +4 -0
  83. data/lib/ecommerce.rb +4 -0
  84. data/lib/ecommerce/engine.rb +6 -0
  85. data/lib/ecommerce/version.rb +3 -0
  86. data/lib/tasks/ecommerce_tasks.rake +4 -0
  87. metadata +185 -0
@@ -0,0 +1,25 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Coupon < CamaleonCms::TermTaxonomy
10
+ default_scope { where(taxonomy: :ecommerce_coupon) }
11
+ belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
12
+ scope :actives, -> {where(status: '1')}
13
+
14
+ def self.find_valid_by_code(code)
15
+ coupon = self.find_by_slug(code.to_s.parameterize)
16
+ if coupon.nil?
17
+ nil
18
+ elsif "#{coupon.options[:expirate_date]} 23:59:59".to_datetime.to_i < Time.now.to_i || coupon.status != '1'
19
+ nil
20
+ else
21
+ coupon
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,60 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::CouponDecorator < CamaleonCms::TermTaxonomyDecorator
10
+ delegate_all
11
+
12
+ # Define presentation-specific methods here. Helpers are accessed through
13
+ # `helpers` (aka `h`). You can override attributes, for example:
14
+ #
15
+ # def created_at
16
+ # helpers.content_tag :span, class: 'time' do
17
+ # object.created_at.strftime("%a %m/%d/%y")
18
+ # end
19
+ # end
20
+
21
+ def the_code
22
+ object.slug.to_s.upcase
23
+ end
24
+
25
+ def the_amount
26
+ opts = object.options
27
+ case opts[:discount_type]
28
+ when 'percent'
29
+ "#{opts[:amount].to_f}%"
30
+ when 'money'
31
+ "#{the_symbol} #{opts[:amount].to_f}"
32
+ else
33
+ "Free"
34
+ end
35
+ end
36
+
37
+ def the_symbol
38
+ opts = object.options
39
+ case opts[:discount_type]
40
+ when 'percent'
41
+ "%"
42
+ when 'money'
43
+ h.current_site.current_unit
44
+ else
45
+ ""
46
+ end
47
+ end
48
+
49
+ def the_status
50
+ opts = object.options
51
+ if "#{opts[:expirate_date]} 23:59:59".to_datetime.to_i < Time.now.to_i
52
+ "<span class='label label-danger'>#{I18n.t('plugin.ecommerce.table.expired')} </span>"
53
+ elsif object.status.to_s.to_bool
54
+ "<span class='label label-success'>#{I18n.t('plugin.ecommerce.active')} </span>"
55
+ else
56
+ "<span class='label label-default'>#{I18n.t('plugin.ecommerce.not_active')} </span>"
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,65 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Order < CamaleonCms::TermTaxonomy
10
+ default_scope { where(taxonomy: :ecommerce_order) }
11
+ has_one :details, class_name: "Plugins::Ecommerce::OrderDetail", foreign_key: :order_id, dependent: :destroy
12
+ has_many :products, foreign_key: :objectid, through: :term_relationships, :source => :objects
13
+ belongs_to :customer, class_name: "CamaleonCms::User", foreign_key: :user_id
14
+
15
+ scope :not_closed, -> { where('status != ?', :closed) }
16
+
17
+ def add_product(object)
18
+ post_id = defined?(object.id) ? object.id : object.to_i
19
+ term_relationships.where(objectid: post_id).first_or_create if post_id > 0
20
+ end
21
+
22
+ def remove_product(object)
23
+ post_id = defined?(object.id) ? object.id : object.to_i
24
+ term_relationships.where(objectid: post_id).destroy_all if post_id > 0
25
+ end
26
+
27
+ def payment_method
28
+ Plugins::Ecommerce::PaymentMethod.find_by_id get_meta("payment")[:payment_id]
29
+ end
30
+
31
+ def payment
32
+ payment = get_meta("payment")
33
+ get_meta("pay_#{payment[:type]}".to_sym)
34
+ end
35
+
36
+ def shipping_method
37
+ Plugins::Ecommerce::ShippingMethod.find_by_id get_meta("payment", {})[:shipping_method]
38
+ end
39
+
40
+ def canceled?
41
+ status == 'canceled'
42
+ end
43
+
44
+ def unpaid?
45
+ status == 'unpaid'
46
+ end
47
+
48
+ def closed?
49
+ status == 'closed'
50
+ end
51
+
52
+ def paid?
53
+ payment.present?
54
+ end
55
+
56
+
57
+ # set user in filter
58
+ def self.set_user(user)
59
+ user_id = defined?(user.id) ? user.id : user.to_i
60
+ self.where(user_id: user_id)
61
+ end
62
+
63
+
64
+ end
65
+ #Cart = Plugins::Ecommerce::Cart
@@ -0,0 +1,54 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::OrderDecorator < CamaleonCms::TermTaxonomyDecorator
10
+ delegate_all
11
+
12
+ # Define presentation-specific methods here. Helpers are accessed through
13
+ # `helpers` (aka `h`). You can override attributes, for example:
14
+ #
15
+ # def created_at
16
+ # helpers.content_tag :span, class: 'time' do
17
+ # object.created_at.strftime("%a %m/%d/%y")
18
+ # end
19
+ # end
20
+
21
+ def the_status
22
+ case self.status
23
+ when 'unpaid'
24
+ "<span class='label label-danger'>#{I18n.t('plugin.ecommerce.select.unpaid')}</span>"
25
+ when 'accepted'
26
+ "<span class='label label-info'>#{I18n.t('plugin.ecommerce.select.accepted')}</span>"
27
+ when 'shipped'
28
+ "<span class='label label-primary'>#{I18n.t('plugin.ecommerce.select.shipped')}</span>"
29
+ when 'closed'
30
+ "<span class='label label-default'>#{I18n.t('plugin.ecommerce.select.closed')}</span>"
31
+ when 'canceled'
32
+ "<span class='label label-default'>#{I18n.t('plugin.ecommerce.select.canceled')}</span>"
33
+ else
34
+ "<span class='label label-success'>#{I18n.t('plugin.ecommerce.select.received')}</span>"
35
+ end
36
+ end
37
+
38
+ def the_pay_status
39
+ if object.paid?
40
+ "<span class='label label-success'>#{I18n.t('plugin.ecommerce.select.received')}</span>"
41
+ elsif object.canceled?
42
+ "<span class='label label-default'>#{I18n.t('plugin.ecommerce.select.canceled')}</span>"
43
+ elsif object.get_meta("payment", {})[:coupon].to_s.parameterize == 'free'
44
+ "<span class='label label-success'>Free</span>"
45
+ else
46
+ "<span class='label label-danger'>#{I18n.t('plugin.ecommerce.select.unpaid')}</span>"
47
+ end
48
+ end
49
+
50
+ def the_url_tracking
51
+ consignment_number = object.get_meta("payment")[:consignment_number] rescue 'none'
52
+ object.shipping_method.options[:url_tracking].gsub("{{consignment_number}}", consignment_number) rescue "#{I18n.t('plugin.ecommerce.message.not_shipped')}"
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::OrderDetail < ActiveRecord::Base
10
+ self.table_name = "plugins_order_details"
11
+ attr_accessible :order_id, :customer, :email, :phone, :status, :received_at, :accepted_at, :shipped_at, :closed_at
12
+ belongs_to :order, class_name: "Plugins::Ecommerce::Order", foreign_key: :order_id
13
+ end
@@ -0,0 +1,29 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::PaymentMethod < CamaleonCms::TermTaxonomy
10
+ default_scope { where(taxonomy: :ecommerce_payment_method) }
11
+ belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
12
+
13
+ scope :actives, -> {where(status: '1')}
14
+
15
+ def method_text
16
+ if options[:type] == 'paypal'
17
+ I18n.t 'plugin.ecommerce.method_paypal'
18
+ elsif options[:type] == 'credit_card'
19
+ I18n.t 'plugin.ecommerce.method_credit_card'
20
+ elsif options[:type] == 'bank_transfer'
21
+ I18n.t 'plugin.ecommerce.method_bank_transfer'
22
+ elsif options[:type] == 'authorize_net'
23
+ I18n.t 'plugin.ecommerce.method_authorize_net'
24
+ else
25
+ 'None'
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,14 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Product < CamaleonCms::Post
10
+ # attrs:
11
+ # slug => plugin key
12
+ #default_scope { where(taxonomy: :e_commerce_product) }
13
+ end
14
+ Product = Plugins::Ecommerce::Product
@@ -0,0 +1,26 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::ShippingMethod < CamaleonCms::TermTaxonomy
10
+ default_scope { where(taxonomy: :ecommerce_shipping_method) }
11
+ belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
12
+
13
+ scope :actives, -> {where(status: '1')}
14
+
15
+ def get_price_from_weight(weight = 0)
16
+ price_total = 0
17
+ prices = get_meta("prices")
18
+ if prices.present?
19
+ prices.each do |key, value|
20
+ price_total = value[:price] if value[:min_weight].to_f <= weight.to_f && value[:max_weight].to_f >= weight.to_f
21
+ end
22
+ end
23
+ price_total.to_f
24
+ end
25
+
26
+ end
@@ -0,0 +1,18 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::TaxRate < CamaleonCms::TermTaxonomy
10
+ default_scope { where(taxonomy: :ecommerce_tax_rate) }
11
+ belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
12
+ scope :actives, -> {where(status: '1')}
13
+
14
+ def the_name
15
+ "#{name} (#{options[:rate]}%)"
16
+ end
17
+
18
+ end
@@ -0,0 +1,3 @@
1
+ <p><%= t('plugin.ecommerce.mail.order_received.welcome') %><%= @extra_data[:fullname] %></p>
2
+ <p><%= t('plugin.ecommerce.mail.order_received.thanks') %></p>
3
+ <p><%= t('plugin.ecommerce.mail.order_received.reference') %> <a href="<%= @extra_data[:order_url] %>"><%= @extra_data[:order_slug] %></a>
@@ -0,0 +1,3 @@
1
+ <p><%= t('plugin.ecommerce.mail.order_received.welcome') %><%= @extra_data[:admin][:fullname] %></p>
2
+ <p><%= @extra_data[:fullname] %> has bought!</p>
3
+ <p><%= t('plugin.ecommerce.mail.order_received.reference') %> <a href="<%= @extra_data[:order_url] %>"><%= @extra_data[:order_slug] %></a>
@@ -0,0 +1,4 @@
1
+ <% order_slug = @extra_data[:order].slug %>
2
+ <p><%= t('plugin.ecommerce.mail.order_received.welcome') %><%= @extra_data[:fullname] %></p>
3
+ <p><%= t('plugin.ecommerce.mail.recovery_cart.body') %></p>
4
+ <p><%= t('plugin.ecommerce.mail.recovery_cart.reference') %> <a href="<%= plugins_ecommerce_order_show_url(order: order_slug) %>"><%= order_slug %></a>
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title></title>
6
+ </head>
7
+ <body>
8
+ <table style="width: 100%">
9
+ <tr>
10
+ <td style="text-align: center; background-color: #fe5e00; padding: 10px;"><img src="http://camaleon.tuzitio.com/media/132/logo2.png"></td>
11
+ </tr>
12
+ <tr>
13
+ <td>
14
+ <%= yield %>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <td style="text-align: center; background-color: #fe5e00;"><a href="<%= @url_base %>" style="color: #ffffff;">Visit Site</a></td>
19
+ </tr>
20
+ </table>
21
+ </body>
22
+ </html>
@@ -0,0 +1,73 @@
1
+ <div class="page-title">
2
+ <h2><span class="fa fa-tag"></span> <%= @coupon.new_record? ? "#{t('plugin.ecommerce.new_coupon')}" : "#{t('plugin.ecommerce.edit_coupon')}: #{@coupon.name}" %></h2>
3
+ </div>
4
+
5
+ <!-- PAGE CONTENT WRAPPER -->
6
+ <div class="page-content-wrap">
7
+
8
+ <div class="row">
9
+ <div class="col-md-8 col-md-offset-2">
10
+ <div class="panel panel-default">
11
+ <div class="panel-heading ui-draggable-handle">
12
+ <h3 class="panel-title"><%= t('plugin.ecommerce.form_coupon') %></h3>
13
+ </div>
14
+ <%= form_for @coupon, url:{action: @coupon.new_record? ? :create : :update}, html: {class: 'validate-coupon', id: 'form-coupon'} do |f| %>
15
+ <div class="panel-body">
16
+ <%= render partial: 'layouts/camaleon_cms/admin/form_error', locals: {data: @coupon} %>
17
+ <div class="form-group">
18
+ <%= f.label t('plugin.ecommerce.table.name') %><br>
19
+ <%= f.text_field :name, :class => "form-control required" %>
20
+ </div>
21
+ <div class="form-group">
22
+ <label for=""><%= t('plugin.ecommerce.table.code') %></label><br>
23
+ <%= f.text_field :slug, :class => "form-control required" %>
24
+ </div>
25
+ <% options = params[:options].present? ? params[:options] : @coupon.options rescue {} %>
26
+ <div class="form-group">
27
+ <label for=""><%= t('plugin.ecommerce.table.amount') %></label><br>
28
+ <%= number_field_tag "options[amount]", options[:amount] || '', :class => "form-control required" %>
29
+ </div>
30
+
31
+ <div class="form-group">
32
+ <label for=""><%= t('plugin.ecommerce.table.discount_type') %></label><br>
33
+ <%= select_tag "options[discount_type]", options_for_select([[t('plugin.ecommerce.table.percent'),"percent"],[t('plugin.ecommerce.table.money'),"money"],[t('plugin.ecommerce.table.free_shipping'),"free_ship"]], options[:discount_type] || ''), :class => "form-control required" %>
34
+ </div>
35
+
36
+ <div class="form-group">
37
+ <label for=""><%= t('plugin.ecommerce.table.min_cart_total') %></label><br>
38
+ <%= text_field_tag "options[min_cart_total]",options[:min_cart_total] || '', :class => "form-control required" %>
39
+ </div>
40
+
41
+ <div class="form-group">
42
+ <label for=""><%= t('plugin.ecommerce.table.expiration_date') %></label><br>
43
+ <%= text_field_tag "options[expirate_date]",options[:expirate_date] || '', :class => "form-control required" %>
44
+ </div>
45
+
46
+ <div class="form-group">
47
+ <label for=""><%= t('plugin.ecommerce.table.allowed_applications') %></label><br>
48
+ <%= number_field_tag "options[allowed_applications]", options[:allowed_applications] || '1', :class => "form-control required" %>
49
+ </div>
50
+
51
+
52
+ <div class="form-group">
53
+ <label><%= f.check_box :status %> &nbsp; <%= t('plugin.ecommerce.active') %></label>
54
+ </div>
55
+ </div>
56
+ <div class="panel-footer">
57
+ <a class="btn btn-default" href="<%= url_for action: :index %>" role="back"><%= t('camaleon_cms.admin.button.back')%></a>
58
+ <button class="btn btn-primary pull-right" type="submit"><%= t('camaleon_cms.admin.button.submit')%></button>
59
+ </div>
60
+ <% end %>
61
+ </div>
62
+
63
+
64
+ </div>
65
+ </div>
66
+ </div>
67
+
68
+ <% add_asset_library('datepicker') %>
69
+ <script>
70
+ run.push(function(){
71
+ jQuery( '#form-coupon' ).on( "change", 'input[type="number"], #options_min_cart_total', function() {setTimeout(function(){jQuery(this).val(Math.abs(jQuery(this).val()) || 0);}.bind(this), 60)});
72
+ })
73
+ </script>
@@ -0,0 +1,50 @@
1
+ <div class="panel panel-default">
2
+ <div class="panel-heading">
3
+ <h4><span class="fa fa-tag"></span> <%= t('plugin.ecommerce.coupons') %></h4>
4
+ <%= link_to raw("<i class='fa fa-plus'></i> #{t('plugin.ecommerce.add_coupons')}"), {action: :new}, class: "btn btn-primary pull-right" %>
5
+ </div>
6
+ <div class="panel-body">
7
+
8
+ <table class="table">
9
+ <thead>
10
+ <tr>
11
+ <th id=""><%= t('plugin.ecommerce.table.code') %></th>
12
+ <th id=""><%= t('plugin.ecommerce.table.name') %></th>
13
+ <th id=""><%= t('plugin.ecommerce.table.status') %></th>
14
+ <th id=""><%= t('plugin.ecommerce.table.amount') %></th>
15
+ <th id=""><%= t('plugin.ecommerce.table.min_cart_total') %></th>
16
+ <th id=""><%= t('plugin.ecommerce.table.expiration_date') %></th>
17
+ <th id=""><%= t('plugin.ecommerce.table.allowed_applications') %></th>
18
+ <th id=""><%= t('plugin.ecommerce.table.used_applications') %></th>
19
+ <th><%= t('plugin.ecommerce.table.actions') %></th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <%
24
+ @coupons.each do |row|
25
+ options = row.options
26
+ row = row.decorate
27
+
28
+ %>
29
+ <tr>
30
+ <td><%= row.the_code %></td>
31
+ <td><%= row.name %></td>
32
+ <td><%= raw row.the_status %></td>
33
+ <td><%= row.the_amount %></td>
34
+ <td><%= options[:min_cart_total] %></td>
35
+ <td><%= options[:expirate_date] %></td>
36
+ <td><%= options[:allowed_applications] %></td>
37
+ <td><%= options[:used_applications] || 0 %></td>
38
+ <td>
39
+ <%= link_to raw('<i class="fa fa-edit"></i>'), {action: :edit, id: row.id}, class: "btn btn-default btn-xs", title: "#{t('camaleon_cms.admin.button.edit')}" %>
40
+ </td>
41
+ </tr>
42
+ <% end %>
43
+
44
+
45
+ </tbody>
46
+ </table>
47
+ <%= content_tag("div", raw(t('camaleon_cms.admin.message.data_found_list')), class: "alert alert-warning") if @coupons.empty? %>
48
+ <%= will_paginate @coupons, renderer: BootstrapPagination::Rails %>
49
+ </div>
50
+ </div>