caboose-cms 0.5.64 → 0.5.66
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin.js +1 -1
- data/app/assets/javascripts/caboose/admin_edit_order.js +724 -0
- data/app/assets/javascripts/caboose/cart2.js +4 -4
- data/app/assets/javascripts/caboose/model/index_table.js +122 -80
- data/app/assets/stylesheets/caboose/admin_main.css +8 -0
- data/app/controllers/caboose/application_controller.rb +1 -1
- data/app/controllers/caboose/block_type_sources_controller.rb +1 -1
- data/app/controllers/caboose/block_types_controller.rb +1 -1
- data/app/controllers/caboose/calendars_controller.rb +1 -1
- data/app/controllers/caboose/cart_controller.rb +8 -1
- data/app/controllers/caboose/checkout_controller.rb +17 -9
- data/app/controllers/caboose/line_items_controller.rb +135 -0
- data/app/controllers/caboose/order_packages_controller.rb +304 -0
- data/app/controllers/caboose/orders_controller.rb +31 -74
- data/app/controllers/caboose/pages_controller.rb +2 -1
- data/app/controllers/caboose/product_images_controller.rb +11 -0
- data/app/controllers/caboose/products_controller.rb +25 -8
- data/app/controllers/caboose/shipping_addresses_controller.rb +46 -0
- data/app/controllers/caboose/shipping_packages_controller.rb +125 -54
- data/app/controllers/caboose/sites_controller.rb +2 -79
- data/app/controllers/caboose/smtp_controller.rb +52 -0
- data/app/controllers/caboose/store_controller.rb +94 -0
- data/app/controllers/caboose/vendors_controller.rb +25 -4
- data/app/models/caboose/address.rb +1 -3
- data/app/models/caboose/caboose_plugin.rb +1 -1
- data/app/models/caboose/category.rb +18 -0
- data/app/models/caboose/core_plugin.rb +21 -19
- data/app/models/caboose/order.rb +12 -7
- data/app/models/caboose/order_package.rb +5 -2
- data/app/models/caboose/order_transaction.rb +25 -0
- data/app/models/caboose/page.rb +1 -1
- data/app/models/caboose/schema.rb +50 -22
- data/app/models/caboose/shipping_calculator.rb +26 -30
- data/app/models/caboose/shipping_package.rb +45 -5
- data/app/models/caboose/store_config.rb +18 -6
- data/app/models/caboose/tax_calculator.rb +6 -5
- data/app/views/caboose/blocks/admin_edit.html.erb +1 -1
- data/app/views/caboose/line_items/admin_new.html.erb +100 -0
- data/app/views/caboose/orders/admin_edit.html.erb +21 -247
- data/app/views/caboose/orders/admin_edit_old.html.erb +155 -0
- data/app/views/caboose/orders/admin_new.html.erb +8 -23
- data/app/views/caboose/products/#Untitled-1# +0 -0
- data/app/views/caboose/products/admin_edit_images.html.erb +20 -4
- data/app/views/caboose/products/admin_index.html.erb +9 -3
- data/app/views/caboose/products/admin_sort.html.erb +138 -142
- data/app/views/caboose/roles/index.html.erb +1 -1
- data/app/views/caboose/shipping_packages/admin_edit.html.erb +52 -137
- data/app/views/caboose/shipping_packages/admin_index.html.erb +56 -19
- data/app/views/caboose/sites/_admin_header.html.erb +3 -5
- data/app/views/caboose/sites/admin_edit.html.erb +5 -3
- data/app/views/caboose/smtp/admin_edit.html.erb +41 -0
- data/app/views/caboose/station/index.html.erb +1 -1
- data/app/views/caboose/store/admin_edit.html.erb +96 -0
- data/app/views/caboose/vendors/admin_edit.html.erb +7 -3
- data/app/views/layouts/caboose/_station.html.erb +1 -1
- data/config/routes.rb +67 -25
- data/lib/caboose/engine.rb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +28 -5
- data/app/views/caboose/shipping_packages/admin_new.html.erb +0 -33
- data/app/views/caboose/sites/admin_edit_smtp_config.html.erb +0 -51
- data/app/views/caboose/sites/admin_edit_store_config.html.erb +0 -77
@@ -11,48 +11,44 @@ module Caboose
|
|
11
11
|
def self.rates(order)
|
12
12
|
return [] if Caboose::store_shipping.nil?
|
13
13
|
|
14
|
-
|
15
|
-
if
|
16
|
-
rates = self.custom_rates(
|
14
|
+
sc = order.site.store_config
|
15
|
+
if sc.shipping_rates_function
|
16
|
+
rates = self.custom_rates(sc, order)
|
17
17
|
return rates
|
18
18
|
end
|
19
|
-
|
20
|
-
ss = Caboose::store_shipping
|
19
|
+
|
21
20
|
origin = Location.new(
|
22
|
-
:country =>
|
23
|
-
:state =>
|
24
|
-
:city =>
|
25
|
-
:zip =>
|
21
|
+
:country => sc.origin_country,
|
22
|
+
:state => sc.origin_state,
|
23
|
+
:city => sc.origin_city,
|
24
|
+
:zip => sc.origin_zip
|
26
25
|
)
|
27
26
|
destination = Location.new(
|
28
|
-
:country =>
|
27
|
+
:country => sc.origin_country,
|
29
28
|
:state => order.shipping_address.state,
|
30
29
|
:city => order.shipping_address.city,
|
31
30
|
:postal_code => order.shipping_address.zip
|
32
|
-
)
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
)
|
32
|
+
carriers = {}
|
33
|
+
carriers['UPS'] = UPS.new( :login => sc.ups_username, :password => sc.ups_password, :key => sc.ups_key, :origin_account => sc.ups_origin_account) if sc.ups_username.strip.length > 0
|
34
|
+
carriers['USPS'] = USPS.new( :login => sc.usps_username) if sc.usps_username.strip.length > 0
|
35
|
+
carriers['FedEx'] = FedEx.new(:login => sc.fedex_username, :password => sc.fedex_password, :key => sc.fedex_key, :account => sc.fedex_account) if sc.fedex_username.strip.length > 0
|
36
|
+
|
36
37
|
all_rates = []
|
37
|
-
order.packages.each do |op|
|
38
|
-
sp = op.shipping_package
|
38
|
+
order.packages.each do |op|
|
39
|
+
sp = op.shipping_package
|
39
40
|
package = op.activemerchant_package
|
40
41
|
rates = []
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if usps
|
49
|
-
resp = usps.find_rates(origin, destination, package)
|
50
|
-
resp.rates.sort_by(&:price).each do |rate|
|
51
|
-
next if rate.service_code != sp.service_code
|
52
|
-
rates << { :carrier => 'USPS', :service_code => rate.service_code, :service_name => rate.service_name, :total_price => rate.total_price.to_d / 100 }
|
42
|
+
carriers.each do |name, carrier|
|
43
|
+
if sp.uses_carrier(name)
|
44
|
+
resp = carrier.find_rates(origin, destination, package)
|
45
|
+
resp.rates.sort_by(&:price).each do |rate|
|
46
|
+
next if !sp.uses_service_code(name, rate.service_code)
|
47
|
+
rates << { :carrier => name, :service_code => rate.service_code, :service_name => rate.service_name, :price => rate.total_price.to_d / 100 }
|
48
|
+
end
|
53
49
|
end
|
54
|
-
end
|
55
|
-
all_rates << { :order_package => op, :rates => rates }
|
50
|
+
end
|
51
|
+
all_rates << { :order_package => op, :rates => rates }
|
56
52
|
end
|
57
53
|
return all_rates
|
58
54
|
end
|
@@ -9,12 +9,17 @@ module Caboose
|
|
9
9
|
attr_accessible :id,
|
10
10
|
:site_id,
|
11
11
|
:name,
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
12
|
+
:inside_length,
|
13
|
+
:inside_width,
|
14
|
+
:inside_height,
|
15
|
+
:outside_length,
|
16
|
+
:outside_width,
|
17
|
+
:outside_height,
|
15
18
|
:volume,
|
19
|
+
:empty_weight,
|
20
|
+
:cylinder,
|
16
21
|
:priority,
|
17
|
-
:flat_rate_price
|
22
|
+
:flat_rate_price
|
18
23
|
|
19
24
|
def fits(variants)
|
20
25
|
|
@@ -36,7 +41,7 @@ module Caboose
|
|
36
41
|
rigid_boxes = self.boxes(rigid)
|
37
42
|
|
38
43
|
it_fits = false
|
39
|
-
BoxPacker.container [self.
|
44
|
+
BoxPacker.container [self.inside_length, self.inside_width, self.inside_height] do
|
40
45
|
rigid_boxes.each{ |arr| add_item arr }
|
41
46
|
count = pack!
|
42
47
|
it_fits = true if count == rigid_boxes.count
|
@@ -86,6 +91,41 @@ module Caboose
|
|
86
91
|
|
87
92
|
return nonstackable
|
88
93
|
end
|
94
|
+
|
95
|
+
def toggle_shipping_method(shipping_method_id, value)
|
96
|
+
if value.to_i > 0 # Add
|
97
|
+
if shipping_method_id == 'all'
|
98
|
+
ShippingPackageMethod.where(:shipping_package_id => self.id).destroy_all
|
99
|
+
ShippingMethod.reorder(:service_name).all.each do |sm|
|
100
|
+
ShippingPackageMethod.create(:shipping_package_id => self.id, :shipping_method_id => sm.id)
|
101
|
+
end
|
102
|
+
else
|
103
|
+
if !ShippingPackageMethod.where(:shipping_package_id => self.id, :shipping_method_id => shipping_method_id.to_i).exists?
|
104
|
+
ShippingPackageMethod.create(:shipping_package_id => self.id, :shipping_method_id => shipping_method_id.to_i)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
else # Remove
|
108
|
+
if shipping_method_id == 'all'
|
109
|
+
ShippingPackageMethod.where(:shipping_package_id => self.id).destroy_all
|
110
|
+
else
|
111
|
+
ShippingPackageMethod.where(:shipping_package_id => self.id, :shipping_method_id => shipping_method_id.to_i).destroy_all
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def uses_carrier(carrier)
|
117
|
+
self.shipping_methods.each do |sm|
|
118
|
+
return true if sm.carrier == carrier
|
119
|
+
end
|
120
|
+
return false
|
121
|
+
end
|
122
|
+
|
123
|
+
def uses_service_code(carrier, service_code)
|
124
|
+
self.shipping_methods.each do |sm|
|
125
|
+
return true if sm.carrier == carrier && sm.service_code == service_code
|
126
|
+
end
|
127
|
+
return false
|
128
|
+
end
|
89
129
|
|
90
130
|
end
|
91
131
|
end
|
@@ -1,23 +1,35 @@
|
|
1
1
|
module Caboose
|
2
2
|
class StoreConfig < ActiveRecord::Base
|
3
|
-
self.table_name = 'store_configs'
|
3
|
+
self.table_name = 'store_configs'
|
4
|
+
|
4
5
|
belongs_to :site
|
5
6
|
attr_accessible :id,
|
6
7
|
:site_id,
|
7
8
|
:pp_name,
|
8
9
|
:pp_username,
|
9
|
-
:pp_password,
|
10
|
-
:
|
10
|
+
:pp_password,
|
11
|
+
:ups_username,
|
12
|
+
:ups_password,
|
13
|
+
:ups_key,
|
14
|
+
:ups_origin_account,
|
15
|
+
:usps_username,
|
11
16
|
:usps_secret_key,
|
12
17
|
:usps_publishable_key,
|
13
|
-
:
|
14
|
-
:
|
18
|
+
:fedex_username,
|
19
|
+
:fedex_password,
|
20
|
+
:fedex_key,
|
21
|
+
:fedex_account,
|
15
22
|
:origin_country,
|
16
23
|
:origin_state,
|
17
24
|
:origin_city,
|
18
25
|
:origin_zip,
|
19
26
|
:fulfillment_email,
|
20
27
|
:shipping_email,
|
21
|
-
:handling_percentage
|
28
|
+
:handling_percentage,
|
29
|
+
:calculate_packages,
|
30
|
+
:shipping_rates_function,
|
31
|
+
:length_unit,
|
32
|
+
:weight_unit
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Caboose
|
2
2
|
class TaxCalculator
|
3
3
|
def self.tax_rate(address)
|
4
|
-
return 0 if address.
|
5
|
-
|
6
|
-
rate = 0.00
|
4
|
+
return 0.00 if address.nil? || address.city.nil? || address.state.nil?
|
5
|
+
return 0 if address.state.downcase != 'al'
|
6
|
+
rate = 0.00
|
7
|
+
city = address.city.downcase
|
7
8
|
rate = rate + 0.05 if city == 'brookwood'
|
8
9
|
rate = rate + 0.05 if city == 'coaling'
|
9
10
|
rate = rate + 0.05 if city == 'coker'
|
@@ -14,8 +15,8 @@ module Caboose
|
|
14
15
|
rate = rate + 0.05 if city == 'northport'
|
15
16
|
rate = rate + 0.05 if city == 'tuscaloosa'
|
16
17
|
rate = rate + 0.05 if city == 'vance'
|
17
|
-
rate = rate + 0.05 if city == 'woodstock'
|
18
|
-
rate = rate + 0.04 if address.state.downcase == 'al' || address.state.downcase == 'alabama'
|
18
|
+
rate = rate + 0.05 if city == 'woodstock'
|
19
|
+
rate = rate + 0.04 if address.state.downcase == 'al' || address.state.downcase == 'alabama'
|
19
20
|
return rate.round(2)
|
20
21
|
end
|
21
22
|
end
|
@@ -44,7 +44,7 @@ end
|
|
44
44
|
<p><div id='block_<%= @block.id %>_value'></div></p>
|
45
45
|
<% else %>
|
46
46
|
<% if @block.children.count > 0 %>
|
47
|
-
<% @block.children.each do |b| %>
|
47
|
+
<% @block.children.order(:id).each do |b| %>
|
48
48
|
<% if b.block_type.field_type != 'block' && b.block_type.field_type != 'richtext' %>
|
49
49
|
<div style='margin-bottom: 10px;'><div id='block_<%= b.id %>_value'></div></div>
|
50
50
|
<% else %>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
<h1>Add Item</h1>
|
3
|
+
|
4
|
+
<p><input type='text' name='product_title' id='product_title' value='' style='width: 400px;' /></p>
|
5
|
+
<div id='products'></div>
|
6
|
+
<div id='variants'></div>
|
7
|
+
<div id='message'></div>
|
8
|
+
|
9
|
+
<p><input type='button' value='Cancel' onclick="modal.close();" /></p>
|
10
|
+
|
11
|
+
<% content_for :caboose_js do %>
|
12
|
+
<%= javascript_include_tag 'caboose/model/all' %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
|
15
|
+
var modal = false;
|
16
|
+
$(window).load(function() {
|
17
|
+
modal = new CabooseModal(600);
|
18
|
+
});
|
19
|
+
|
20
|
+
$(document).ready(function() {
|
21
|
+
$('#product_title').on('keyup', function() { show_products(); });
|
22
|
+
});
|
23
|
+
|
24
|
+
function show_products()
|
25
|
+
{
|
26
|
+
var title = $('#product_title').val();
|
27
|
+
$.ajax({
|
28
|
+
url: '/admin/orders/line-items/product-stubs',
|
29
|
+
type: 'get',
|
30
|
+
data: { title: title },
|
31
|
+
success: function(products) {
|
32
|
+
if (products && products.length > 0)
|
33
|
+
{
|
34
|
+
var ul = $('<ul/>');
|
35
|
+
$.each(products, function(i, p) {
|
36
|
+
ul.append($('<li/>')
|
37
|
+
.attr('id', 'product_id_' + p.id)
|
38
|
+
.data('product_id', p.id)
|
39
|
+
.append($('<a/>').html(p.title).click(function(e) {
|
40
|
+
e.preventDefault();
|
41
|
+
show_variants($(e.target).parent(), $(e.target).parent().data('product_id'));
|
42
|
+
}))
|
43
|
+
);
|
44
|
+
});
|
45
|
+
$('#products').empty().append(ul);
|
46
|
+
}
|
47
|
+
else
|
48
|
+
{
|
49
|
+
$('#products').empty().append($('<p/>').html('No products met your search.'));
|
50
|
+
}
|
51
|
+
modal.autosize();
|
52
|
+
}
|
53
|
+
});
|
54
|
+
}
|
55
|
+
|
56
|
+
var open_product_id = false;
|
57
|
+
|
58
|
+
function show_variants(li, product_id)
|
59
|
+
{
|
60
|
+
if (open_product_id && open_product_id == product_id)
|
61
|
+
{
|
62
|
+
$('#product_id_' + open_product_id).find('ul').remove();
|
63
|
+
open_product_id = false;
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
if (open_product_id)
|
67
|
+
{
|
68
|
+
$('#product_id_' + open_product_id).find('ul').remove();
|
69
|
+
open_product_id = false;
|
70
|
+
}
|
71
|
+
open_product_id = product_id;
|
72
|
+
$.ajax({
|
73
|
+
url: '/admin/products/' + product_id + '/variants/json',
|
74
|
+
type: 'get',
|
75
|
+
success: function(resp) {
|
76
|
+
var ul = $('<ul/>');
|
77
|
+
$.each(resp.models, function(i, v) {
|
78
|
+
var name = [];
|
79
|
+
if (v.option1) name.push(v.option1);
|
80
|
+
if (v.option2) name.push(v.option2);
|
81
|
+
if (v.option3) name.push(v.option3);
|
82
|
+
name = name.join(' / ');
|
83
|
+
ul.append($('<li/>')
|
84
|
+
.data('variant_id', v.id)
|
85
|
+
.append($('<a/>').html(name).click(function(e) {
|
86
|
+
e.preventDefault();
|
87
|
+
variant_id = $(e.target).parent().data('variant_id');
|
88
|
+
parent.controller.add_variant(variant_id);
|
89
|
+
modal.close();
|
90
|
+
}))
|
91
|
+
);
|
92
|
+
});
|
93
|
+
li.append(ul);
|
94
|
+
modal.autosize();
|
95
|
+
}
|
96
|
+
});
|
97
|
+
}
|
98
|
+
|
99
|
+
</script>
|
100
|
+
<% end %>
|
@@ -1,106 +1,10 @@
|
|
1
|
-
|
2
|
-
sa = @order.shipping_address
|
3
|
-
shipping_address = sa.address1
|
4
|
-
shipping_address << "<br />#{sa.address2}" if sa.address2 && sa.address2.length > 0
|
5
|
-
shipping_address << "<br />#{sa.city}, #{sa.state} #{sa.zip}"
|
6
|
-
captured = @order.financial_status == 'captured'
|
7
|
-
%>
|
1
|
+
|
8
2
|
<input type='hidden' name='order_id' id='order_id' value='<%= @order.id %>' />
|
9
3
|
|
10
4
|
<h1>Edit Order #<%= @order.id %></h1>
|
11
|
-
|
12
|
-
<table class='data'>
|
13
|
-
<tr>
|
14
|
-
<th><%= if @order.customer.nil? then 'Guest' else 'Customer' end %></th>
|
15
|
-
<th>Shipping Address</th>
|
16
|
-
<th>Shipping Method</th>
|
17
|
-
<th>Order Status</th>
|
18
|
-
<th>Payment Status</th>
|
19
|
-
<th>Transaction ID</th>
|
20
|
-
</tr>
|
21
|
-
<tr>
|
22
|
-
<td valign='top'>
|
23
|
-
<%= "#{@order.shipping_address.first_name} #{@order.shipping_address.last_name}" %><br />
|
24
|
-
<% if @order.customer %>
|
25
|
-
<a href="mailto:<%= "#{@order.customer.email}" %>"><%= "#{@order.customer.email}" %></a><br />
|
26
|
-
<% elsif @order.email %>
|
27
|
-
<a href="mailto:<%= @order.email %>"><%= @order.email %></a>
|
28
|
-
<% end %>
|
29
|
-
<%= @order.customer ? @order.customer.phone : @order.shipping_address.phone %>
|
30
|
-
</td>
|
31
|
-
<td valign='top'>
|
32
|
-
<%= "#{@order.shipping_address.first_name} #{@order.shipping_address.last_name}" %><br />
|
33
|
-
<%= raw shipping_address %>
|
34
|
-
</td>
|
35
|
-
<td valign='top' align='center'>
|
36
|
-
<% if @order.shipping_service_code %>
|
37
|
-
<%= @order.shipping_carrier %> <%= @order.shipping_service_name %>
|
38
|
-
<% else %>
|
39
|
-
Multiple packages
|
40
|
-
<% end %>
|
41
|
-
</td>
|
42
|
-
<td valign='top'>
|
43
|
-
<div id='order_<%= @order.id %>_status'></div>
|
44
|
-
</td>
|
45
|
-
<td valign='top' align='center'>
|
46
|
-
<%= @order.financial_status %>
|
47
|
-
<% if @order.financial_status == 'authorized' %>
|
48
|
-
for<br /><%= number_to_currency(@order.auth_amount) %>
|
49
|
-
<% end %>
|
50
|
-
</td>
|
51
|
-
<td valign="top" align='center'><%= @order.transaction_id %></td>
|
52
|
-
</tr>
|
53
|
-
</table><br />
|
54
|
-
|
55
|
-
<table class='data' width='100%'>
|
56
|
-
<tr>
|
57
|
-
<th>Item</th>
|
58
|
-
<th>Status</th>
|
59
|
-
<th>Tracking Number</th>
|
60
|
-
<th>Unit Price</th>
|
61
|
-
<th>Quantity</th>
|
62
|
-
<th>Subtotal</th>
|
63
|
-
</tr>
|
64
|
-
<% @order.line_items.each do |li| %>
|
65
|
-
<tr>
|
66
|
-
<td>
|
67
|
-
<% if li.variant.nil? || li.variant.product.nil? %>
|
68
|
-
<% if li.variant.nil? %>
|
69
|
-
Unknown variant
|
70
|
-
<% else %>
|
71
|
-
<%= li.variant.sku %>
|
72
|
-
<% end %>
|
73
|
-
<% else %>
|
74
|
-
<a href='/admin/products/<%= li.variant.product.id %>/variants?highlight=<%= li.variant.id %>'><%= li.variant.product.title %></a><br />
|
75
|
-
<%= li.variant.sku %><br />
|
76
|
-
<%= li.variant.title %>
|
77
|
-
<% end %>
|
78
|
-
</td>
|
79
|
-
<td ><div id='lineitem_<%= li.id %>_status' ></div></td>
|
80
|
-
<td ><div id='lineitem_<%= li.id %>_tracking_number' ></div></td>
|
81
|
-
<td align='right'><%= number_to_currency(li.variant.price) %></td>
|
82
|
-
<td align='right'><% if captured %><%= li.quantity %><% else %><div id='lineitem_<%= li.id %>_quantity'></div><% end %></td>
|
83
|
-
<td align='right' id='li_<%= li.id %>_subtotal'><%= number_to_currency(li.price) %></td>
|
84
|
-
</tr>
|
85
|
-
<% end %>
|
86
|
-
<tr><td colspan='5' align='right'>Subtotal </td><td align='right' id='subtotal' ><%= number_to_currency(@order.subtotal ) %></td></tr>
|
87
|
-
<tr><td colspan='5' align='right'>Tax </td><td align='right' id='tax' ><%= number_to_currency(@order.tax ) %></td></tr>
|
88
|
-
<tr><td colspan='5' align='right'><%= @order.shipping_service_code ? @order.shipping_service_code : '' %> Shipping & Handling </td><td align='right' id='shipping'><%= number_to_currency(@order.shipping + @order.handling) %></td></tr>
|
89
|
-
<tr>
|
90
|
-
<td colspan='5' align='right'>Discount</td>
|
91
|
-
<td align='right'>
|
92
|
-
<% if captured && @order.discounts.any? %>
|
93
|
-
<%= number_to_currency(@order.amount_discounted || 0) %>
|
94
|
-
<% elsif @order.discounts.any? %>
|
95
|
-
<%= number_to_currency(@order.discounts.first.amount_current) %>
|
96
|
-
<% else %>
|
97
|
-
$0.00
|
98
|
-
<% end %>
|
99
|
-
</td>
|
100
|
-
</tr>
|
101
5
|
|
102
|
-
<
|
103
|
-
|
6
|
+
<div id='overview_table'></div>
|
7
|
+
<div id='order_table'></div>
|
104
8
|
<div id='message'></div>
|
105
9
|
|
106
10
|
<p>
|
@@ -113,6 +17,7 @@ captured = @order.financial_status == 'captured'
|
|
113
17
|
<input type='button' value='Refund' onclick="refund_order(<%= @order.id %>);" />
|
114
18
|
<% end %>
|
115
19
|
<input type='button' value='Resend Confirmation' onclick="resend_confirmation(<%= @order.id %>)" />
|
20
|
+
<input type='button' value='Add Item' onclick="controller.add_variant();" />
|
116
21
|
<input type='button' value='Print Order' onclick="print_order(<%= @order.id %>);" />
|
117
22
|
|
118
23
|
<% str = Caboose.plugin_hook('admin_edit_order_buttons', "", @order) %>
|
@@ -121,159 +26,28 @@ captured = @order.financial_status == 'captured'
|
|
121
26
|
|
122
27
|
<% content_for :caboose_js do %>
|
123
28
|
<%= javascript_include_tag 'caboose/model/all' %>
|
29
|
+
<%= javascript_include_tag 'caboose/admin_edit_order' %>
|
124
30
|
<script type='text/javascript'>
|
125
31
|
|
126
|
-
|
127
|
-
{
|
128
|
-
modal.autosize("<p class='loading'>Resending confirmation..</p>");
|
129
|
-
$.ajax({
|
130
|
-
type: 'post',
|
131
|
-
url: '/admin/orders/' + order_id + '/resend-confirmation',
|
132
|
-
success: function(resp) {
|
133
|
-
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
134
|
-
if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
135
|
-
}
|
136
|
-
});
|
137
|
-
}
|
138
|
-
|
139
|
-
function capture_funds(order_id, confirm)
|
140
|
-
{
|
141
|
-
total = $('#total').html();
|
142
|
-
if (!confirm)
|
143
|
-
{
|
144
|
-
var p = $('<p/>').addClass('note confirm')
|
145
|
-
.append("Are you sure you want to charge " + total + " to the customer? ")
|
146
|
-
.append($('<input/>').attr('type','button').val('Yes').click(function() { capture_funds(order_id, true); }))
|
147
|
-
.append(' ')
|
148
|
-
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
149
|
-
modal.autosize(p);
|
150
|
-
return;
|
151
|
-
}
|
152
|
-
modal.autosize("<p class='loading'>Capturing funds...</p>");
|
153
|
-
$.ajax({
|
154
|
-
url: '/admin/orders/' + order_id + '/capture',
|
155
|
-
success: function(resp) {
|
156
|
-
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
157
|
-
if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
158
|
-
if (resp.refresh) window.location.reload(true);
|
159
|
-
}
|
160
|
-
});
|
161
|
-
}
|
162
|
-
|
163
|
-
function void_order(order_id, confirm)
|
164
|
-
{
|
165
|
-
if (!confirm)
|
166
|
-
{
|
167
|
-
var p = $('<p/>').addClass('note confirm')
|
168
|
-
.append("Are you sure you want to void this order? ")
|
169
|
-
.append($('<input/>').attr('type','button').val('Yes').click(function() { void_order(order_id, true); }))
|
170
|
-
.append(' ')
|
171
|
-
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
172
|
-
modal.autosize(p);
|
173
|
-
return;
|
174
|
-
}
|
175
|
-
modal.autosize("<p class='loading'>Voiding...</p>");
|
176
|
-
$.ajax({
|
177
|
-
url: '/admin/orders/' + order_id + '/void',
|
178
|
-
success: function(resp) {
|
179
|
-
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
180
|
-
if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
181
|
-
if (resp.refresh) window.location.reload(true);
|
182
|
-
}
|
183
|
-
});
|
184
|
-
}
|
185
|
-
|
186
|
-
function refund_order(order_id, confirm)
|
187
|
-
{
|
188
|
-
if (!confirm)
|
189
|
-
{
|
190
|
-
var p = $('<p/>').addClass('note confirm')
|
191
|
-
.append("Are you sure you want to refund this order? ")
|
192
|
-
.append($('<input/>').attr('type','button').val('Yes').click(function() { refund_order(order_id, true); }))
|
193
|
-
.append(' ')
|
194
|
-
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
195
|
-
modal.autosize(p);
|
196
|
-
return;
|
197
|
-
}
|
198
|
-
modal.autosize("<p class='loading'>Refunding...</p>");
|
199
|
-
$.ajax({
|
200
|
-
url: '/admin/orders/' + order_id + '/refund',
|
201
|
-
success: function(resp) {
|
202
|
-
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
203
|
-
if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
204
|
-
if (resp.refresh) window.location.reload(true);
|
205
|
-
}
|
206
|
-
});
|
207
|
-
}
|
208
|
-
|
209
|
-
function print_order(order_id)
|
210
|
-
{
|
211
|
-
window.open('/admin/orders/' + order_id + '/print');
|
212
|
-
}
|
213
|
-
|
32
|
+
var controller = false;
|
214
33
|
$(document).ready(function() {
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
id: <%= li.id %>,
|
219
|
-
update_url: '/admin/orders/<%= @order.id %>/line-items/<%= li.id %>',
|
220
|
-
authenticity_token: '<%= form_authenticity_token %>',
|
221
|
-
attributes: [
|
222
|
-
{ name: 'status' , nice_name: 'Status' , type: 'select' , align: 'left' , value: <%= raw Caboose.json(li.status ) %>, text: <%= raw Caboose.json(li.status ) %>, width: 150, fixed_placeholder: false, options_url: '/admin/orders/line-item-status-options' },
|
223
|
-
{ name: 'tracking_number' , nice_name: 'Tracking Number' , type: 'text' , align: 'left' , value: <%= raw Caboose.json(li.tracking_number ) %>, width: 200, fixed_placeholder: false },
|
224
|
-
{ name: 'quantity' , nice_name: 'Quantity' , type: 'text' , align: 'right', value: <%= raw Caboose.json(li.quantity ) %>, width: 75, fixed_placeholder: false,
|
225
|
-
before_update: function() {
|
226
|
-
modal.autosize("<p class='loading'>Recalculating tax, shipping and handling...</p>");
|
227
|
-
},
|
228
|
-
after_update: function() {
|
229
|
-
var order_id = $('#order_id').val();
|
230
|
-
$.ajax({
|
231
|
-
url: '/admin/orders/' + order_id + '/json',
|
232
|
-
success: function(order) {
|
233
|
-
$.each(order.order_line_items, function(i, li) {
|
234
|
-
$('#li_' + li.id + '_subtotal').html('$' + parseFloat(li.variant.price * li.quantity).toFixed(2));
|
235
|
-
});
|
236
|
-
var sah = parseFloat(order.shipping) + parseFloat(order.handling);
|
237
|
-
$('#subtotal' ).html('$' + parseFloat(order.subtotal ).toFixed(2));
|
238
|
-
$('#subtotal' ).html('$' + parseFloat(order.subtotal ).toFixed(2));
|
239
|
-
$('#tax' ).html('$' + parseFloat(order.tax ).toFixed(2));
|
240
|
-
$('#shipping' ).html('$' + parseFloat(sah ).toFixed(2));
|
241
|
-
$('#total' ).html('$' + parseFloat(order.total ).toFixed(2));
|
242
|
-
$('#order_total').val(parseFloat(order.total).toFixed(2));
|
243
|
-
$('#message').empty();
|
244
|
-
modal.autosize();
|
245
|
-
}
|
246
|
-
});
|
247
|
-
}
|
248
|
-
}
|
249
|
-
]
|
250
|
-
});
|
251
|
-
<% end %>
|
252
|
-
|
253
|
-
new ModelBinder({
|
254
|
-
name: 'Order',
|
255
|
-
id: <%= @order.id %>,
|
256
|
-
update_url: '/admin/orders/<%= @order.id %>',
|
257
|
-
authenticity_token: '<%= form_authenticity_token %>',
|
258
|
-
attributes: [
|
259
|
-
{
|
260
|
-
name: 'status',
|
261
|
-
nice_name: 'Status',
|
262
|
-
type: 'select',
|
263
|
-
value: <%= raw Caboose.json(@order.status) %>,
|
264
|
-
text: <%= raw Caboose.json(@order.status) %>,
|
265
|
-
width: 100,
|
266
|
-
options_url: '/admin/orders/status-options',
|
267
|
-
fixed_placeholder: false
|
268
|
-
}
|
269
|
-
]
|
34
|
+
controller = new OrderController({
|
35
|
+
order_id: <%= raw Caboose.json(@order.id) %>,
|
36
|
+
authenticity_token: <%= raw Caboose.json(form_authenticity_token) %>
|
270
37
|
});
|
271
38
|
});
|
272
39
|
|
273
|
-
var modal = false;
|
274
|
-
$(window).load(function() {
|
275
|
-
modal = new CabooseModal('95%');
|
276
|
-
});
|
277
|
-
|
278
40
|
</script>
|
279
41
|
<% end %>
|
42
|
+
|
43
|
+
<% content_for :caboose_css do %>
|
44
|
+
<style type='text/css'>
|
45
|
+
|
46
|
+
table.shipping_address td {
|
47
|
+
padding: 0 !important;
|
48
|
+
margin: 0 !important;
|
49
|
+
border: 0 !important;
|
50
|
+
}
|
51
|
+
|
52
|
+
</style>
|
53
|
+
<% end %>
|