caboose-cms 0.5.132 → 0.5.133

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmIwMjBmY2NmYzVkZGUzYzgwZmZkMzY5NTYzM2FkOTc0ZTYwZWYwZA==
4
+ OWFlOGY4NzlmM2I5NzkxYTQyZmRiMjYxZjJiMDFjZDE2ZTAxMTcxOA==
5
5
  data.tar.gz: !binary |-
6
- MmU2ZjNjYjg0MTQ4NjIyMjRmNDlmZWE5ZWNjODYxNDAyNmJlNjJlZg==
6
+ YTRjYjA3N2IwMjdlMjM2MTkxMGNkYWZhYTY1OGMzNmNmMzAzNDdlNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGI5OGU2ZjZlNTJjMmM0YjQwODkzNjI4NDc5OTMzMjgxY2Q4NmQ1MTJkNzcx
10
- OGJlZWI0ZDM1MWExMDc3ZGE3NGNmMDVlYWNkMDliOTg5ZTU2Mzg4MTQyYWQy
11
- ODkyNjZjNDhjMGU0Mjg0ZDI2MGExMWUxNDQzNDgxMmFiYjM0Yjk=
9
+ YTFjOWNiYmEwMjYxYTBhN2YwNjA1NjJjZDU0NjRmNmQyNjE4NzZlNjVlNmMy
10
+ M2EwMWQyZDA1MmY5NTkyNmI2ODc5YTgxZGViODRmOTg3ZWY5MDI2NTMyODU5
11
+ ZmU3ZTk5NDY0Y2FjZGI2NGE1M2ViZGM3ZTY0ZGVlOGM4ODRjMjM=
12
12
  data.tar.gz: !binary |-
13
- ZjdhOTYyZjI0MDQ0OWNmNDAzMmQzNGFkY2ExYzViYzlmZmNhYTZjNzM2ZmEy
14
- YWRhOWQ4ZWZkOTI4OTk1OGJjNTZiYzkyZjYwNTRmZjg0NjM5MzYwNGU5MTQ0
15
- ZWUxYmNkNmYwZDc2ODViMjg3NmY2ZDMwMGMxODI5MzQwNWY0NWE=
13
+ M2RhOWQyZjFmOGQ0ZDJiZmViZjVkMmYyNzczNDdkYzUxNGMxM2FmZGJjNGUx
14
+ ZTFmZTI1OWMxN2MzMThhYTAwNGViNWFiMThiNzVlNDIyYWQ0MTE0Yjg1Zjk3
15
+ NzI0MjExZWNlYjMxYjA1ZjU0MzNmYmZiNjdmZDQ2ZDIxYzJlM2U=
@@ -9,7 +9,9 @@ Cart.prototype = {
9
9
  show_total: true,
10
10
  show_shipping: true,
11
11
  show_tax: true,
12
+ show_gift_wrap: true,
12
13
  show_discounts: true,
14
+ show_gift_options: true,
13
15
 
14
16
  init: function(params)
15
17
  {
@@ -58,6 +60,44 @@ Cart.prototype = {
58
60
  var item = $('<td/>').attr('valign', 'top').append(p.title + '<br/>' + v.title);
59
61
  if (that.allow_edit_line_items == true)
60
62
  item.append('<br/>').append($('<a/>').attr('href','#').html('Remove').click(function(e) { e.preventDefault(); that.remove_item(li.id); }));
63
+ if (that.show_gift_options)
64
+ {
65
+ if (this.allow_edit_line_items)
66
+ {
67
+ item
68
+ .append($('<div/>').addClass('gift_options_checkbox')
69
+ .append($('<table/>')
70
+ .append($('<tbody/>')
71
+ .append($('<tr/>').append($('<td/>').addClass('checkbox').append($('<div/>').attr('id', 'lineitem_' + li.id + '_is_gift' ))).append($('<td/>').append("This item is a gift")))
72
+ )
73
+ )
74
+ )
75
+ .append($('<div/>').attr('id', 'gift_options_' + li.id).addClass('gift_options').css('display', li.is_gift ? 'block' : 'none')
76
+ .append($('<table/>')
77
+ .append($('<tbody/>')
78
+ .append($('<tr/>').append($('<td/>').addClass('checkbox').append($('<div/>').attr('id', 'lineitem_' + li.id + '_gift_wrap' ))).append($('<td/>').append("Gift wrap ($" + parseFloat(li.variant.product.gift_wrap_price).toFixed(2) + ')')))
79
+ .append($('<tr/>').append($('<td/>').addClass('checkbox').append($('<div/>').attr('id', 'lineitem_' + li.id + '_hide_prices'))).append($('<td/>').append("Hide prices in receipt")))
80
+ .append($('<tr/>').append($('<td/>').attr('colspan', '2').append('Gift message<br/>').append($('<div/>').attr('id', 'lineitem_' + li.id + '_gift_message'))))
81
+ )
82
+ )
83
+ );
84
+ }
85
+ else
86
+ {
87
+ if (li.is_gift)
88
+ {
89
+ item.append($('<ul/>').addClass('gift_options')
90
+ .append($('<li/>').html("This item is a gift."))
91
+ .append($('<li/>').html("Gift wrap? " + (li.gift_wrap ? 'Yes' : 'No')))
92
+ .append($('<li/>').html("Hide prices? " + (li.hide_prices ? 'Yes' : 'No')))
93
+ .append($('<li/>').html("Gift message: " + (li.gift_message.length > 0 ? li.gift_message : '[Empty]')))
94
+ );
95
+ }
96
+ else
97
+ item.append("This item is not a gift.")
98
+ }
99
+ }
100
+
61
101
  var qty = $('<td/>').css('text-align', 'right');
62
102
  if (that.allow_edit_line_items == true)
63
103
  qty.append($('<div/>').attr('id', 'lineitem_' + li.id + '_quantity'));
@@ -83,6 +123,13 @@ Cart.prototype = {
83
123
  .append($('<td/>').css('text-align', 'right').html('$' + parseFloat(that.order.shipping + that.order.handling).toFixed(2)))
84
124
  );
85
125
  }
126
+ if (that.show_gift_wrap)
127
+ {
128
+ tbody.append($('<tr/>')
129
+ .append($('<td/>').css('text-align', 'right').attr('colspan', 4).html('Gift Wrapping'))
130
+ .append($('<td/>').css('text-align', 'right').html('$' + parseFloat(that.order.gift_wrap).toFixed(2)))
131
+ );
132
+ }
86
133
  if (that.show_tax)
87
134
  {
88
135
  tbody.append($('<tr/>')
@@ -120,21 +167,40 @@ Cart.prototype = {
120
167
  );
121
168
  }
122
169
  $('#cart').empty().append($('<table/>').append(tbody));
123
-
124
- if (that.allow_edit_line_items)
170
+
171
+ // Make anything editable that needs to be
172
+ if (this.allow_edit_line_items)
125
173
  {
126
- $.each(this.order.line_items, function(i, li) {
174
+ $.each(this.order.line_items, function(i, li) {
175
+ var p = li.variant.product;
176
+ var attribs = [];
177
+ if (that.allow_edit_line_items)
178
+ attribs.push({ name: 'quantity', nice_name: 'Qty', type: 'text', value: li.quantity, width: 50, fixed_placeholder: false, after_update: function() { that.refresh(); } });
179
+ if (that.show_gift_options)
180
+ {
181
+ attribs.push({ name: 'is_gift' , nice_name: 'This item is a gift' , type: 'checkbox' , value: li.is_gift , width: 40 , fixed_placeholder: false, after_update: function() { that.toggle_gift_options(this.li_id); }, li_id: li.id });
182
+ attribs.push({ name: 'hide_prices' , nice_name: 'Hide prices' , type: 'checkbox' , value: li.hide_prices , width: 40 , fixed_placeholder: false, after_update: function() { } });
183
+ attribs.push({ name: 'gift_wrap' , nice_name: 'Gift wrap' , type: 'checkbox' , value: li.gift_wrap , width: 40 , fixed_placeholder: false, after_update: function() { that.refresh(); } });
184
+ attribs.push({ name: 'gift_message' , nice_name: 'Gift message' , type: 'textarea' , value: li.gift_message , width: 400 , height: 75 , fixed_placeholder: false, after_update: function() { } });
185
+ }
127
186
  m = new ModelBinder({
128
187
  name: 'LineItem',
129
188
  id: li.id,
130
189
  update_url: '/cart/' + li.id,
131
190
  authenticity_token: that.form_authenticity_token,
132
- attributes: [
133
- { name: 'quantity', nice_name: 'Qty', type: 'text', value: li.quantity, width: 50, fixed_placeholder: false, after_update: function() { that.refresh(); } }
134
- ]
135
- });
191
+ attributes: attribs
192
+ });
136
193
  });
137
- }
194
+ }
195
+ },
196
+
197
+ toggle_gift_options: function(li_id)
198
+ {
199
+ var el = $('#gift_options_' + li_id);
200
+ if (el.is(':visible'))
201
+ el.slideUp();
202
+ else
203
+ el.slideDown();
138
204
  },
139
205
 
140
206
  remove_item: function(li_id)
@@ -21,7 +21,8 @@ BoundTextarea = BoundControl.extend({
21
21
  );
22
22
  $('#'+this.el+'_container').empty();
23
23
  $('#'+this.el+'_container').append($('<textarea/>').attr('id', this.el).attr('placeholder', 'empty').val(this.attribute.value));
24
- $('#'+this.el+'_container').append($('<div/>').attr('id', this.el + '_placeholder').addClass('mb_placeholder').append($('<span/>').html(this.attribute.nice_name + ': ')));
24
+ if (this.attribute.fixed_placeholder)
25
+ $('#'+this.el+'_container').append($('<div/>').attr('id', this.el + '_placeholder').addClass('mb_placeholder').append($('<span/>').html(this.attribute.nice_name + ': ')));
25
26
  if (this.attribute.width) $('#'+this.el).css('width' , this.attribute.width);
26
27
  if (this.attribute.height) $('#'+this.el).css('height' , this.attribute.height);
27
28
  var h = $('#'+this.el+'_placeholder').outerHeight();
@@ -5,6 +5,18 @@
5
5
  table { border-collapse: collapse; width: 100%; }
6
6
  table th { font-weight: bold; text-align: center; }
7
7
  table td { border: #ccc 1px solid; padding: 10px; }
8
+ .gift_options {
9
+ table td { border: 0; }
10
+ table td.checkbox { margin: 0; padding: 0; width: 20px; }
11
+ .mb_checkbox_background { display: none; }
12
+ .mb_container input[type="checkbox"] { position: relative; margin-left: -10px; width: auto; top: 0; }
13
+ }
14
+ .gift_options_checkbox {
15
+ table td { border: 0; }
16
+ table td.checkbox { margin: 0; padding: 0; width: 20px; }
17
+ .mb_checkbox_background { display: none; }
18
+ .mb_container input[type="checkbox"] { position: relative; margin-left: -10px; width: auto; top: 0; }
19
+ }
8
20
 
9
21
  input[type="text"] {
10
22
  border-color: #b9b9b9;
@@ -65,14 +65,33 @@ module Caboose
65
65
  end
66
66
 
67
67
  # PUT /cart/:line_item_id
68
- def update
68
+ def update
69
+ resp = Caboose::StdClass.new
69
70
  li = LineItem.find(params[:line_item_id])
70
- li.quantity = params[:quantity].to_i
71
- li.subtotal = li.unit_price * li.quantity
71
+
72
+ save = true
73
+ params.each do |name,value|
74
+ case name
75
+ when 'quantity' then
76
+ li.quantity = value.to_i
77
+ if li.quantity == 0
78
+ li.destroy
79
+ else
80
+ li.subtotal = li.unit_price * li.quantity
81
+ li.save
82
+ li.order.calculate
83
+ end
84
+ when 'is_gift' then li.is_gift = value
85
+ when 'include_gift_message' then li.include_gift_message = value
86
+ when 'gift_message' then li.gift_message = value
87
+ when 'gift_wrap' then li.gift_wrap = value
88
+ when 'hide_prices' then li.hide_prices = value
89
+ end
90
+ end
72
91
  li.save
73
- li.destroy if li.quantity == 0
74
- @order.calculate_subtotal
75
- render :json => { :success => true }
92
+ li.order.calculate
93
+ resp.success = true
94
+ render :json => resp
76
95
  end
77
96
 
78
97
  # DELETE /cart/:line_item_id
@@ -47,7 +47,7 @@ module Caboose
47
47
  config = YAML.load_file("#{::Rails.root}/config/aws.yml")
48
48
  bucket = AWS::S3::Bucket.new(config[Rails.env]['bucket'])
49
49
  s3object = AWS::S3::S3Object.new(bucket, li.variant.download_path)
50
- url = s3object.url_for(:read, :expires => sc.download_url_expires_in.minutes).to_s
50
+ url = s3object.url_for(:read, :expires => sc.download_url_expires_in.to_i.minutes).to_s
51
51
 
52
52
  redirect_to url
53
53
  end
@@ -53,6 +53,7 @@ module Caboose
53
53
  def admin_edit
54
54
  return if !user_is_allowed('orders', 'edit')
55
55
  @order = Order.find(params[:id])
56
+ @order.calculate
56
57
  render :layout => 'caboose/admin'
57
58
  end
58
59
 
@@ -200,13 +201,13 @@ module Caboose
200
201
  ])
201
202
  end
202
203
 
203
- # GET /admin/orders/:id/print
204
+ # GET /admin/orders/:id/print.pdf
204
205
  def admin_print
205
206
  return if !user_is_allowed('orders', 'edit')
206
207
 
207
208
  pdf = OrderPdf.new
208
209
  pdf.order = Order.find(params[:id])
209
- send_data pdf.to_pdf, :filename => "order_#{pdf.order.id}.pdf", :type => "application/pdf", :disposition => "inline"
210
+ send_data pdf.to_pdf, :filename => "order_#{pdf.order.id}.pdf", :type => "application/pdf", :disposition => "inline"
210
211
  end
211
212
 
212
213
  # GET /admin/orders/print-pending
@@ -179,8 +179,8 @@ module Caboose
179
179
  x = 0.0
180
180
  self.line_items.each do |li|
181
181
  next if !li.gift_wrap
182
- next if !li.product.allow_gift_wrap
183
- x = x + li.product.gift_wrap_price * li.quantity
182
+ next if !li.variant.product.allow_gift_wrap
183
+ x = x + li.variant.product.gift_wrap_price * li.quantity
184
184
  end
185
185
  return x
186
186
  end
@@ -73,7 +73,7 @@ module Caboose
73
73
  end
74
74
  end
75
75
  line_items = h.sort_by{ |k,v| k }.collect{ |x| x[1] }
76
- all_packages = ShippingPackage.reorder(:price).all
76
+ all_packages = ShippingPackage.reorder(:flat_rate_price).all
77
77
 
78
78
  # Now go through each variant and fit it in a new or existing package
79
79
  line_items.each do |li|
@@ -9,12 +9,21 @@ module Caboose
9
9
 
10
10
  # Get the type of card and last four digits
11
11
  get_card_details
12
-
12
+
13
+ font_size 9
14
+
15
+ img = open("http://cabooseit.s3.amazonaws.com/uploads/template.jpg")
16
+ # image img, :width => 610, :at => [-30, 755]
17
+
13
18
  #image open("https://dmwwflw4i3miv.cloudfront.net/logo.png"), :position => :center
14
- text " "
15
- customer_info
16
- text " "
19
+ move_down 10
20
+ order_info
21
+ move_down 15
17
22
  order_table
23
+ move_down 15
24
+ customer_info
25
+ move_down 15
26
+ payment_info
18
27
  render
19
28
  end
20
29
 
@@ -38,42 +47,81 @@ module Caboose
38
47
  t = AuthorizeNet::Reporting::Transaction.new(sc.pp_username, sc.pp_password)
39
48
  resp = t.get_transaction_details(ot.transaction_id)
40
49
  t2 = resp.transaction
41
- self.card_type = t2.payment_method.card_type
50
+ self.card_type = t2.payment_method.card_type.upcase
42
51
  self.card_number = t2.payment_method.card_number.gsub('X', '')
43
52
 
44
53
  end
45
54
 
46
55
  end
56
+
57
+ def order_info
58
+
59
+ order_info = "Order Number: #{order.id}\n"
60
+ order_info << "Order Date: #{order.date_created.strftime('%d %b %Y %H:%M:%S %p')}\n"
61
+ order_info << "Status: #{order.status.capitalize}\n"
62
+ tbl = []
63
+ tbl << [
64
+ { :content => order_info }
65
+ ]
66
+ move_down 4
67
+ table tbl, :position => 7, :width => 530
68
+ end
69
+
47
70
 
48
71
  def customer_info
49
-
50
- order_info = "Order ##{order.id}\n"
51
- order_info << "Status: #{order.status.capitalize}\n"
52
- order_info << "Received: #{order.date_created.strftime("%m/%d/%Y")}\n"
53
- if order.status == 'shipped' && order.date_shipped
54
- order_info << "Shipped: #{order.date_shipped.strftime("%m/%d/%Y")}"
55
- end
56
-
72
+
57
73
  c = order.customer
58
- billed_to = "#{c.first_name} #{c.last_name}\n#{c.email}\n#{self.formatted_phone(c.phone)}\n#{self.card_type} ending in #{self.card_number}"
74
+
75
+ # #{self.card_type} ending in #{self.card_number
76
+ ba = order.billing_address
77
+ billed_to = []
78
+ billed_to << [
79
+ { :content => "Name", :border_width => 0 },
80
+ { :content => "#{ba.first_name} #{ba.last_name}", :border_width => 0}
81
+ ]
82
+ billed_to << [
83
+ { :content => "Address", :border_width => 0 },
84
+ { :content => "#{ba.address1}" + (ba.address2.blank? ? '' : "\n#{ba.address2}") + "\n#{ba.city}, #{ba.state} #{ba.zip}", :border_width => 0}
85
+ ]
86
+ billed_to << [
87
+ { :content => "Email", :border_width => 0 },
88
+ { :content => "#{c.email}", :border_width => 0}
89
+ ]
90
+ billed_to << [
91
+ { :content => "Phone", :border_width => 0 },
92
+ { :content => "#{self.formatted_phone(c.phone)}", :border_width => 0}
93
+ ]
59
94
 
60
95
  sa = order.shipping_address
61
- shipped_to = "#{sa.name}\n#{sa.address1}\n"
62
- shipped_to << "#{sa.address2}\n" if sa.address2.strip.length > 0
63
- shipped_to << "#{sa.city}, #{sa.state} #{sa.zip}"
64
-
96
+ shipped_to = []
97
+ shipped_to << [
98
+ { :content => "Name", :border_width => 0 },
99
+ { :content => "#{sa.first_name} #{sa.last_name}", :border_width => 0}
100
+ ]
101
+ shipped_to << [
102
+ { :content => "Address", :border_width => 0 },
103
+ { :content => "#{sa.address1}" + (sa.address2.blank? ? '' : "\n#{sa.address2}") + "\n#{sa.city}, #{sa.state} #{sa.zip}", :border_width => 0}
104
+ ]
105
+ shipped_to << [
106
+ { :content => "Email", :border_width => 0 },
107
+ { :content => "#{c.email}", :border_width => 0}
108
+ ]
109
+ shipped_to << [
110
+ { :content => "Phone", :border_width => 0 },
111
+ { :content => "#{self.formatted_phone(c.phone)}", :border_width => 0}
112
+ ]
113
+
65
114
  tbl = []
66
115
  tbl << [
67
- { :content => "Order Info" , :align => :center, :valign => :bottom, :width => 180 },
68
- { :content => "Billed To" , :align => :center, :valign => :bottom, :width => 180 },
69
- { :content => "Shipped To" , :align => :center, :valign => :bottom, :width => 180 }
116
+ { :content => "Shipping Information" , :align => :left, :width => 255, :font_style => :bold },
117
+ { :content => "Billing Information" , :align => :left, :width => 255, :font_style => :bold }
70
118
  ]
71
119
  tbl << [
72
- { :content => order_info, :valign => :top, :height => 75 },
73
- { :content => billed_to , :valign => :top, :height => 75 },
74
- { :content => shipped_to, :valign => :top, :height => 75 }
75
- ]
76
- table tbl
120
+ { :content => shipped_to },
121
+ { :content => billed_to }
122
+ ]
123
+ move_down 4
124
+ table tbl, :position => 7, :width => 530
77
125
 
78
126
  end
79
127
 
@@ -81,29 +129,124 @@ module Caboose
81
129
 
82
130
  tbl = []
83
131
  tbl << [
84
- { :content => "Item" , :align => :center, :valign => :bottom },
85
- { :content => "Tracking Number" , :align => :center, :valign => :bottom },
86
- { :content => "Unit Price" , :align => :center, :valign => :bottom },
87
- { :content => "Quantity" , :align => :center, :valign => :bottom },
88
- { :content => "Subtotal" , :align => :center, :valign => :bottom, :width => 60 }
132
+ { :content => "Package" , :align => :left, :valign => :bottom },
133
+ { :content => "Product" , :align => :left, :valign => :bottom, :colspan => 2 },
134
+ { :content => "Attributes" , :align => :left, :valign => :bottom },
135
+ { :content => "Quantity" , :align => :right, :valign => :bottom },
136
+ { :content => "Price" , :align => :right, :valign => :bottom },
137
+ { :content => "Amount" , :align => :right, :valign => :bottom }
89
138
  ]
139
+
140
+ order.calculate
90
141
 
91
- order.line_items.each do |li|
92
- tbl << [
93
- "#{li.variant.product.title}\n#{li.variant.sku}\n#{li.variant.title}",
94
- { :content => li.tracking_number },
95
- { :content => sprintf("%.2f", li.unit_price) , :align => :right },
96
- { :content => "#{li.quantity}" , :align => :right },
97
- { :content => sprintf("%.2f", li.subtotal) , :align => :right }
98
- ]
99
- end
100
- tbl << [{ :content => "Subtotal" , :colspan => 4, :align => :right }, { :content => sprintf("%.2f", order.subtotal ) , :align => :right }]
101
- tbl << [{ :content => "Tax" , :colspan => 4, :align => :right }, { :content => sprintf("%.2f", order.tax ? order.tax : 0.0 ) , :align => :right }]
102
- #tbl << [{ :content => "#{order.shipping_method} Shipping & Handling" , :colspan => 4, :align => :right }, { :content => sprintf("%.2f", order.shipping_and_handling ) , :align => :right }]
103
- tbl << [{ :content => "Discount" , :colspan => 4, :align => :right }, { :content => sprintf("%.2f", order.discount ? order.discount : 0.0 ) , :align => :right }]
104
- tbl << [{ :content => "Total" , :colspan => 4, :align => :right }, { :content => sprintf("%.2f", order.total ) , :align => :right }]
142
+ order.order_packages.each do |pk|
143
+
144
+ carrier = pk.shipping_method.carrier
145
+ service = pk.shipping_method.service_name
146
+ package = pk.shipping_package.name
147
+
148
+ pk.line_items.each_with_index do |li, index|
149
+ options = ''
150
+ if li.variant.product.option1 && li.variant.option1 then options += li.variant.product.option1 + ": " + li.variant.option1 + "\n" end
151
+ if li.variant.product.option2 && li.variant.option2 then options += li.variant.product.option2 + ": " + li.variant.option2 + "\n" end
152
+ if li.variant.product.option3 && li.variant.option3 then options += li.variant.product.option3 + ": " + li.variant.option3 + "\n" end
153
+ if li.variant.product.product_images.count > 0
154
+ image = open("#{li.variant.product.product_images.first.url(:tiny)}")
155
+ else
156
+ image = ""
157
+ end
158
+ arr = []
159
+ if index == 0
160
+ arr << { :content => package + "\n" + carrier + "\n" + service, :width => 115, :rowspan => (index == 0 ? pk.line_items.count : 1) }
161
+ end
162
+
163
+ arr << { :image => image, :fit => [40, 40], :borders => [:top, :bottom, :left], :width => 50 }
164
+ arr << { :content => "#{li.variant.product.title}\n#{li.variant.sku}", :borders => [:top, :right, :bottom], :width => 100 }
165
+ arr << { :content => options }
166
+ arr << { :content => "#{li.quantity}" , :align => :right }
167
+ arr << { :content => "$" + sprintf("%.2f", li.price) , :align => :right }
168
+ arr << { :content => "$" + sprintf("%.2f", li.subtotal) , :align => :right }
169
+
170
+ tbl << arr
171
+
172
+ end
173
+ end
174
+
175
+ unassigned = order.line_items.where("order_package_id IS NULL OR order_package_id = ?",-1)
176
+ unassigned.each_with_index do |li, index|
177
+ options = ''
178
+ if li.variant.product.option1 && li.variant.option1 then options += li.variant.product.option1 + ": " + li.variant.option1 + "\n" end
179
+ if li.variant.product.option2 && li.variant.option2 then options += li.variant.product.option2 + ": " + li.variant.option2 + "\n" end
180
+ if li.variant.product.option3 && li.variant.option3 then options += li.variant.product.option3 + ": " + li.variant.option3 + "\n" end
181
+ if li.variant.product.product_images.count > 0
182
+ image = open("#{li.variant.product.product_images.first.url(:tiny)}")
183
+ else
184
+ image = ""
185
+ end
186
+ arr = []
187
+ if index == 0
188
+ arr << { :content => "Unassigned", :width => 115, :rowspan => (index == 0 ? unassigned.count : 1) }
189
+ end
190
+ arr << { :image => image, :fit => [40, 40], :borders => [:top, :bottom, :left], :width => 50 }
191
+ arr << { :content => "#{li.variant.product.title}\n#{li.variant.sku}", :borders => [:top, :right, :bottom], :width => 100 }
192
+ arr << { :content => options }
193
+ arr << { :content => "#{li.quantity}" , :align => :right }
194
+ arr << { :content => "$" + sprintf("%.2f", li.price) , :align => :right }
195
+ arr << { :content => "$" + sprintf("%.2f", li.subtotal) , :align => :right }
196
+ tbl << arr
197
+ end
198
+
199
+ tbl << [{ :content => "Subtotal" , :colspan => 6, :align => :right }, { :content => "$" + sprintf("%.2f", order.subtotal ) , :align => :right }]
200
+ tbl << [{ :content => "Discount" , :colspan => 6, :align => :right }, { :content => "(-) $" + sprintf("%.2f", order.discount ? order.discount : 0.0 ) , :align => :right }]
201
+ tbl << [{ :content => "Shipping and Handling Charges" , :colspan => 6, :align => :right }, { :content => "(+) $" + sprintf("%.2f", order.shipping_and_handling ) , :align => :right }]
202
+ tbl << [{ :content => "Sales Tax" , :colspan => 6, :align => :right }, { :content => "(+) $" + sprintf("%.2f", order.tax ? order.tax : 0.0 ) , :align => :right }]
203
+ tbl << [{ :content => "Grand Total" , :colspan => 6, :font_style => :bold, :align => :right }, { :content => "$" + sprintf("%.2f", order.total ) , :align => :right, :font_style => :bold }]
105
204
 
106
- table tbl
205
+ table tbl , :position => 7, :width => 530
107
206
  end
207
+
208
+ def payment_info
209
+
210
+ trans = order.order_transactions.where(:transaction_type => OrderTransaction::TYPE_AUTHORIZE, :success => true).first
211
+ tbl = []
212
+ tbl2 = []
213
+ tbl3 = []
214
+
215
+ tbl2 << [
216
+ { :content => "Card Type", :width => 127, :border_width => 0 },
217
+ { :content => self.card_type, :width => 128, :border_width => 0 }
218
+ ]
219
+ tbl2 << [
220
+ { :content => "Transaction ID", :width => 127, :border_width => 0 },
221
+ { :content => trans.transaction_id.to_s, :width => 128, :border_width => 0 }
222
+ ]
223
+ tbl2 << [
224
+ { :content => "Gateway Response", :width => 127, :border_width => 0},
225
+ { :content => trans.response_code.to_s, :width => 128, :border_width => 0 }
226
+ ]
227
+ tbl3 << [
228
+ { :content => "Card Number", :width => 127, :border_width => 0},
229
+ { :content => "XXXX XXXX XXXX " + self.card_number, :width => 128, :border_width => 0 }
230
+ ]
231
+ tbl3 << [
232
+ { :content => "Transaction Time", :width => 127, :border_width => 0},
233
+ { :content => trans.date_processed.strftime("%d %b %Y %H:%M:%S %p"), :width => 128, :border_width => 0 }
234
+ ]
235
+ tbl3 << [
236
+ { :content => "Payment Process", :width => 127, :border_width => 0},
237
+ { :content => trans.success ? "Successful" : "Failed", :width => 128, :border_width => 0 }
238
+ ]
239
+ tbl << [
240
+ { :content => "Authorization Details", :colspan => 2, :font_style => :bold }
241
+ ]
242
+ tbl << [
243
+ { :content => tbl2, :width => 255 },
244
+ { :content => tbl3, :width => 255 }
245
+ ]
246
+
247
+ table tbl, :position => 7, :width => 530
248
+
249
+ end
250
+
108
251
  end
109
252
  end
@@ -15,9 +15,7 @@ store_config = @site.store_config
15
15
  <input type="hidden" id="x_city" name="x_city" value="<%= raw @order.billing_address.city %>" />
16
16
  <input type="hidden" id="x_state" name="x_state" value="<%= raw @order.billing_address.state %>" />
17
17
  <input type="hidden" id="x_zip" name="x_zip" value="<%= raw @order.billing_address.zip %>" />
18
-
19
-
20
-
18
+
21
19
  <div class="field" id="credit-card">
22
20
  <span class="field-text">Credit Card</span>
23
21
  <div class="icons">
@@ -1 +1,3 @@
1
1
  <h1>Thank you for your order!</h1>
2
+
3
+
@@ -55,6 +55,8 @@ $(document).ready(function() {
55
55
  { show: false, name: 'featured' , nice_name: 'Featured' , sort: 'featured' , type: 'checkbox' , value: function(p) { return p.featured }, width: 200 },
56
56
  { show: false, name: 'category_id' , nice_name: 'Categories' , sort: 'categories.name' , type: 'checkbox-multiple' , value: function(p) { return p.categories ? p.categories.map(function(c) { return c.id }) : []; }, text: function(p) { return p.categories ? p.categories.map(function(c) { return c.name }).join(', ') : ''; }, width: 200, height: 200, options_url: '/admin/categories/options' },
57
57
  { show: true , name: 'stackable_group_id' , nice_name: 'Stackable Group' , sort: 'stackable_group_id' , type: 'select' , value: function(p) { return p.stackable_group_id }, width: 200, options_url: '/admin/stackable-groups/options' },
58
+ { show: false, name: 'allow_gift_wrap' , nice_name: 'Allow Gift Wrap' , sort: 'allow_gift_wrap' , type: 'checkbox' , value: function(p) { return p.allow_gift_wrap ? 'Yes' : 'No' }, width: 500 },
59
+ { show: false, name: 'gift_wrap_price' , nice_name: 'Gift Wrap Price' , sort: 'gift_wrap_price' , type: 'text' , value: function(p) { return p.gift_wrap_price.length > 0 ? '$' + parseFloat(p.gift_wrap_price).toFixed(2) : '' }, width: 500 }
58
60
  ],
59
61
  new_model_text: 'New Product',
60
62
  new_model_fields: [
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.5.132'
2
+ VERSION = '0.5.133'
3
3
  end
@@ -80,6 +80,20 @@ namespace :caboose do
80
80
  end
81
81
  end
82
82
  end
83
+
84
+ desc "Remove invalid variant images"
85
+ task :remove_invalid_variant_images => :environment do
86
+
87
+ Caboose::Product.reorder(:id).all.each do |p|
88
+ ids = p.product_images.collect{ |img| img.id }
89
+ p.variants.each do |v|
90
+ v.product_image_variants.all.each do |piv|
91
+ piv.destroy if !ids.include?(piv.product_image_id)
92
+ end
93
+ end
94
+ end
95
+
96
+ end
83
97
 
84
98
  #=============================================================================
85
99
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.132
4
+ version: 0.5.133
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg