caboose-cms 0.8.38 → 0.8.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f74cebbce6c78f175007af58a31fc7ca382b619
4
- data.tar.gz: a10f38da20b59896b341aed745f641f329a73633
3
+ metadata.gz: 99ae29203df95c60378f40de21837b5aefedec12
4
+ data.tar.gz: f6835c1bc2774a5c97863ec6de0d37f1103ee939
5
5
  SHA512:
6
- metadata.gz: f6f84435f2749865dac686fa7c14862bfe1abf9bb7777f0fbaafdd9e081bff8d08d04443bb8155740f81145df52b8080de769b36db532619e644f045ab863460
7
- data.tar.gz: 1b272c8e6da0cf640fda7d847fb922711585df512707ca37cb09ee31a11a2a3a64e301710bda29933a177b5f6aea10e0da846151a9b6b47a86676b2fc7027e64
6
+ metadata.gz: 444cc4df3817be4c231b9c73874a409c6da44bd98f6ae225e489ed0cd791e3fc1ad296ce85214f2895f3195a4efac126eee74167448e09a10593b1677a8b9a42
7
+ data.tar.gz: 84bc7fec0c54554fdd662b6d5ed15291505df0e1abd4fb3eef81595ed6910da4f4d9e2e3f7a77ea769204c6e3d17fa2520882ad17bde7e17eab16e571d4b0a89
@@ -268,16 +268,18 @@ InvoiceController.prototype = {
268
268
  {
269
269
  var that = this;
270
270
 
271
+ var requires_shipping = that.invoice_requires_shipping();
271
272
  var transactions = that.transactions_table();
272
273
  var table = $('<table/>').addClass('data');
273
- table.append($('<tr/>')
274
- .append($('<th/>').html('Customer'))
275
- .append($('<th/>').html('Shipping Address'))
276
- .append($('<th/>').html('Billing Address'))
277
- .append($('<th/>').html('Invoice Status'))
278
- .append($('<th/>').html('Payment'))
279
- );
280
- table.append($('<tr/>')
274
+ var tr =
275
+ $('<tr/>').append($('<th/>').html('Customer'));
276
+ if (requires_shipping)
277
+ tr.append($('<th/>').html('Shipping Address'))
278
+ //.append($('<th/>').html('Billing Address'))
279
+ tr.append($('<th/>').html('Invoice Status'))
280
+ .append($('<th/>').html('Payment'));
281
+ table.append(tr);
282
+ tr = $('<tr/>')
281
283
  .append($('<td/>').attr('valign', 'top')
282
284
  .append($('<div/>').attr('id', 'customer').append(that.noneditable_customer(true)))
283
285
  .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
@@ -287,17 +289,22 @@ InvoiceController.prototype = {
287
289
  else { that.noneditable_customer(); a.html('Edit'); }
288
290
  });
289
291
  }))
290
- )
291
- .append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(that.noneditable_shipping_address()))
292
- .append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
293
- .append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_status')))
292
+ );
293
+ if (requires_shipping)
294
+ {
295
+ tr.append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(
296
+ requires_shipping ? that.noneditable_shipping_address() : "This invoice doesn't require shipping."
297
+ ));
298
+ }
299
+ //.append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
300
+ tr.append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_status')))
294
301
  .append($('<td/>').attr('valign', 'top')
295
302
  .append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_payment_terms'))
296
303
  .append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_payment_terms'))
297
304
  .append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_financial_status'))
298
305
  .append($('<div/>').attr('id', 'transactions').attr('align', 'center').append(transactions))
299
- )
300
- );
306
+ );
307
+ table.append(tr);
301
308
  return table;
302
309
  },
303
310
 
@@ -407,73 +414,73 @@ InvoiceController.prototype = {
407
414
  });
408
415
  },
409
416
 
410
- noneditable_billing_address: function()
411
- {
412
- var that = this;
413
-
414
- var sa = that.invoice.billing_address;
415
- if (!sa) sa = {};
416
- var str = '';
417
- str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
418
- str += (sa.last_name ? sa.last_name : '[Empty last name]');
419
- str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
420
- if (sa.address2) str += "<br />" + sa.address2;
421
- str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
422
-
423
- var div = $('<div/>')
424
- .append(str)
425
- .append("<br />")
426
- .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
427
- var a = $(this);
428
- that.refresh_invoice(function() { that.edit_billing_address(); });
429
- }));
430
- return div;
431
- },
432
-
433
- edit_billing_address: function()
434
- {
435
- var that = this;
436
- var sa = that.invoice.billing_address;
437
- if (!sa) sa = { id: 1 };
438
- var table = $('<table/>').addClass('billing_address')
439
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
440
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
441
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
442
- ))))
443
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
444
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
445
- ))))
446
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
447
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
448
- ))))
449
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
450
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
451
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
452
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
453
- ))));
454
- $('#billing_address').empty()
455
- .append(table)
456
- .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
457
- var a = $(this);
458
- that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
459
- }));
460
-
461
- new ModelBinder({
462
- name: 'BillingAddress',
463
- id: sa.id,
464
- update_url: '/admin/invoices/' + that.invoice.id + '/billing-address',
465
- authenticity_token: that.authenticity_token,
466
- attributes: [
467
- { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
468
- { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
469
- { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
470
- { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
471
- { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
472
- { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
473
- { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
474
- ]
475
- });
476
- },
417
+ //noneditable_billing_address: function()
418
+ //{
419
+ // var that = this;
420
+ //
421
+ // var sa = that.invoice.billing_address;
422
+ // if (!sa) sa = {};
423
+ // var str = '';
424
+ // str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
425
+ // str += (sa.last_name ? sa.last_name : '[Empty last name]');
426
+ // str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
427
+ // if (sa.address2) str += "<br />" + sa.address2;
428
+ // str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
429
+ //
430
+ // var div = $('<div/>')
431
+ // .append(str)
432
+ // .append("<br />")
433
+ // .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
434
+ // var a = $(this);
435
+ // that.refresh_invoice(function() { that.edit_billing_address(); });
436
+ // }));
437
+ // return div;
438
+ //},
439
+ //
440
+ //edit_billing_address: function()
441
+ //{
442
+ // var that = this;
443
+ // var sa = that.invoice.billing_address;
444
+ // if (!sa) sa = { id: 1 };
445
+ // var table = $('<table/>').addClass('billing_address')
446
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
447
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
448
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
449
+ // ))))
450
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
451
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
452
+ // ))))
453
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
454
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
455
+ // ))))
456
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
457
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
458
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
459
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
460
+ // ))));
461
+ // $('#billing_address').empty()
462
+ // .append(table)
463
+ // .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
464
+ // var a = $(this);
465
+ // that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
466
+ // }));
467
+ //
468
+ // new ModelBinder({
469
+ // name: 'BillingAddress',
470
+ // id: sa.id,
471
+ // update_url: '/admin/invoices/' + that.invoice.id + '/billing-address',
472
+ // authenticity_token: that.authenticity_token,
473
+ // attributes: [
474
+ // { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
475
+ // { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
476
+ // { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
477
+ // { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
478
+ // { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
479
+ // { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
480
+ // { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
481
+ // ]
482
+ // });
483
+ //},
477
484
 
478
485
  // Show all the packages and the line items in each package
479
486
  invoice_packages_table: function(table)
@@ -643,6 +650,7 @@ InvoiceController.prototype = {
643
650
  {
644
651
  var that = this;
645
652
 
653
+ var requires_shipping = that.invoice_requires_shipping();
646
654
  var has_unassigned_line_items = false
647
655
  $.each(that.invoice.line_items, function(i, li) {
648
656
  if (!li.invoice_package_id || li.invoice_package_id == -1)
@@ -653,38 +661,44 @@ InvoiceController.prototype = {
653
661
  });
654
662
  if (!has_unassigned_line_items)
655
663
  return;
656
-
657
- table.append($('<tr/>')
658
- .append($('<th/>').html('Package' ))
659
- .append($('<th/>').html('Item' ))
664
+
665
+ var tr = $('<tr/>');
666
+ if (requires_shipping) tr.append($('<th/>').html('Package' ));
667
+ tr.append($('<th/>').html('Item' ))
660
668
  .append($('<th/>').html('Status' ))
661
669
  .append($('<th/>').html('Unit Price' ))
662
670
  .append($('<th/>').html('Quantity' ))
663
- .append($('<th/>').html('Subtotal' ))
664
- );
665
-
671
+ .append($('<th/>').html('Subtotal' ))
672
+ table.append(tr);
673
+
666
674
  $.each(that.invoice.line_items, function(i, li) {
667
675
  if (li.invoice_package_id && li.invoice_package_id != -1) return true;
668
-
669
- var div = false;
670
676
 
671
- if (li.variant.downloadable)
677
+ var tr = $('<tr/>');
678
+ if (requires_shipping)
672
679
  {
673
- div = $('<div/>').append('This item is downloadable.');
674
- }
675
- else
676
- {
677
- div = $('<div/>').attr('id', 'assign_to_package_' + li.id)
678
- .append('Unpackaged! ')
679
- .append($('<a/>').data('line_item_id', li.id).attr('href', '#').html('Assign to package').click(function(e) {
680
- e.preventDefault();
681
- e.stopPropagation();
682
- that.assign_to_package_form($(this).data('line_item_id'));
683
- }));
680
+ var div = false;
681
+ if (li.variant.downloadable)
682
+ {
683
+ div = $('<div/>').append('This item is downloadable.');
684
+ }
685
+ else if (!li.variant.requires_shipping)
686
+ {
687
+ div = $('<div/>').append("This items doesn't require shipping.");
688
+ }
689
+ else
690
+ {
691
+ div = $('<div/>').attr('id', 'assign_to_package_' + li.id)
692
+ .append('Unpackaged! ')
693
+ .append($('<a/>').data('line_item_id', li.id).attr('href', '#').html('Assign to package').click(function(e) {
694
+ e.preventDefault();
695
+ e.stopPropagation();
696
+ that.assign_to_package_form($(this).data('line_item_id'));
697
+ }));
698
+ }
699
+ tr.append($('<td/>').append(div));
684
700
  }
685
-
686
- var tr = $('<tr/>');
687
- tr.append($('<td/>').append(div));
701
+
688
702
  tr.append($('<td/>')
689
703
  .append(that.line_item_link(li))
690
704
  .append(that.gift_options(li))
@@ -703,22 +717,23 @@ InvoiceController.prototype = {
703
717
  summary_table: function(table)
704
718
  {
705
719
  var that = this;
720
+ var requires_shipping = that.invoice_requires_shipping();
706
721
  if (that.invoice.line_items.length > 0 || that.invoice.invoice_packages.length > 0)
707
722
  {
708
- table.append($('<tr/>').append($('<th/>').attr('colspan', '6').html('&nbsp;')));
723
+ table.append($('<tr/>').append($('<th/>').attr('colspan', requires_shipping ? '6' : '5').html('&nbsp;')));
709
724
  }
710
725
 
711
726
  if (that.invoice.line_items.length > 0)
712
727
  {
713
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.invoice.subtotal))));
714
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').append('Tax ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_tax(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_tax'))));
715
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.invoice.shipping))));
716
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').append('Handling ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_handling(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_handling'))));
728
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.invoice.subtotal))));
729
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').append('Tax ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_tax(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_tax'))));
730
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.invoice.shipping))));
731
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').append('Handling ' ).append($('<a/>').attr('href', '#').html('(calculate)').click(function(e) { e.preventDefault(); that.calculate_handling(); }))).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_handling'))));
717
732
  if (that.invoice.discounts)
718
733
  {
719
734
  $.each(that.invoice.discounts, function(i, d) {
720
735
  table.append($('<tr/>')
721
- .append($('<td/>').attr('colspan', '5').attr('align', 'right')
736
+ .append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right')
722
737
  .append($('<a/>').attr('href', '#').html('Remove').click(function(e) { that.remove_discount(d.id); }))
723
738
  .append(' "' + d.gift_card.code + '" Discount')
724
739
  )
@@ -726,12 +741,12 @@ InvoiceController.prototype = {
726
741
  );
727
742
  });
728
743
  }
729
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_custom_discount'))));
730
- table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total').html(curr(that.invoice.total))));
744
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_custom_discount'))));
745
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total').html(curr(that.invoice.total))));
731
746
  }
732
747
  else
733
748
  {
734
- table.append($('<tr/>').append($('<td/>').attr('colspan', '6')
749
+ table.append($('<tr/>').append($('<td/>').attr('colspan', requires_shipping ? '6' : '5')
735
750
  .append($('<p/>')
736
751
  .append('There are no items in this invoice. ')
737
752
  .append($('<a/>').attr('href','#').html('Add one!').click(function(e) {
@@ -1145,7 +1160,18 @@ InvoiceController.prototype = {
1145
1160
  }
1146
1161
  });
1147
1162
  return t;
1148
- }
1163
+ },
1164
+
1165
+ invoice_requires_shipping: function()
1166
+ {
1167
+ var that = this;
1168
+ var requires = false;
1169
+ $.each(that.invoice.line_items, function(i, li) {
1170
+ if (li.requires_shipping && !li.downloadable)
1171
+ requires = true;
1172
+ });
1173
+ return requires;
1174
+ }
1149
1175
  };
1150
1176
 
1151
1177
  function formatted_date(str)
@@ -92,6 +92,7 @@ MyAccountInvoiceController.prototype = {
92
92
  {
93
93
  var that = this;
94
94
 
95
+ var requires_shipping = that.invoice_requires_shipping();
95
96
  var fstatus = $('<div/>').append($('<p/>').html(capitalize_first_letter(that.invoice.financial_status)));
96
97
  if (that.invoice.financial_status == 'pending')
97
98
  {
@@ -99,20 +100,22 @@ MyAccountInvoiceController.prototype = {
99
100
  }
100
101
 
101
102
  var table = $('<table/>').addClass('invoice');
102
- table.append($('<tr/>')
103
- .append($('<th/>').html('Customer'))
104
- .append($('<th/>').html('Shipping Address'))
105
- .append($('<th/>').html('Billing Address'))
106
- .append($('<th/>').html('Status'))
107
- .append($('<th/>').html('Payment Status'))
108
- );
109
- table.append($('<tr/>')
110
- .append($('<td/>').attr('valign', 'top').attr('id', 'customer' ).append(that.noneditable_customer()))
111
- .append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(that.noneditable_shipping_address()))
112
- .append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
113
- .append($('<td/>').attr('valign', 'top').attr('align', 'center').append($('<p/>').html(capitalize_first_letter(that.invoice.status))))
114
- .append($('<td/>').attr('valign', 'top').attr('id', 'financial_status' ).attr('align', 'center').append(fstatus))
115
- );
103
+ var tr = $('<tr/>')
104
+ .append($('<th/>').html('Customer'));
105
+ if (requires_shipping)
106
+ tr.append($('<th/>').html('Shipping Address'))
107
+ //.append($('<th/>').html('Billing Address'))
108
+ tr.append($('<th/>').html('Status'))
109
+ .append($('<th/>').html('Payment Status'));
110
+ table.append(tr);
111
+ tr = $('<tr/>')
112
+ .append($('<td/>').attr('valign', 'top').attr('id', 'customer' ).append(that.noneditable_customer()));
113
+ if (requires_shipping)
114
+ tr.append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(that.noneditable_shipping_address()))
115
+ //.append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
116
+ tr.append($('<td/>').attr('valign', 'top').attr('align', 'center').append($('<p/>').html(capitalize_first_letter(that.invoice.status))))
117
+ .append($('<td/>').attr('valign', 'top').attr('id', 'financial_status' ).attr('align', 'center').append(fstatus));
118
+ table.append(tr);
116
119
  return table;
117
120
  },
118
121
 
@@ -203,73 +206,73 @@ MyAccountInvoiceController.prototype = {
203
206
  });
204
207
  },
205
208
 
206
- noneditable_billing_address: function()
207
- {
208
- var that = this;
209
-
210
- var sa = that.invoice.billing_address;
211
- if (!sa) sa = {};
212
- var str = '';
213
- str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
214
- str += (sa.last_name ? sa.last_name : '[Empty last name]');
215
- str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
216
- if (sa.address2) str += "<br />" + sa.address2;
217
- str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
218
-
219
- var div = $('<div/>')
220
- .append(str)
221
- .append("<br />")
222
- .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
223
- var a = $(this);
224
- that.refresh_invoice(function() { that.edit_billing_address(); });
225
- }));
226
- return div;
227
- },
228
-
229
- edit_billing_address: function()
230
- {
231
- var that = this;
232
- var sa = that.invoice.billing_address;
233
- if (!sa) sa = { id: 1 };
234
- var table = $('<table/>').addClass('billing_address')
235
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
236
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
237
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
238
- ))))
239
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
240
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
241
- ))))
242
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
243
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
244
- ))))
245
- .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
246
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
247
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
248
- .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
249
- ))));
250
- $('#billing_address').empty()
251
- .append(table)
252
- .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
253
- var a = $(this);
254
- that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
255
- }));
256
-
257
- new ModelBinder({
258
- name: 'BillingAddress',
259
- id: sa.id,
260
- update_url: '/my-account/invoices/' + that.invoice.id + '/billing-address',
261
- authenticity_token: that.authenticity_token,
262
- attributes: [
263
- { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
264
- { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
265
- { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
266
- { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
267
- { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
268
- { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
269
- { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
270
- ]
271
- });
272
- },
209
+ //noneditable_billing_address: function()
210
+ //{
211
+ // var that = this;
212
+ //
213
+ // var sa = that.invoice.billing_address;
214
+ // if (!sa) sa = {};
215
+ // var str = '';
216
+ // str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
217
+ // str += (sa.last_name ? sa.last_name : '[Empty last name]');
218
+ // str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
219
+ // if (sa.address2) str += "<br />" + sa.address2;
220
+ // str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
221
+ //
222
+ // var div = $('<div/>')
223
+ // .append(str)
224
+ // .append("<br />")
225
+ // .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
226
+ // var a = $(this);
227
+ // that.refresh_invoice(function() { that.edit_billing_address(); });
228
+ // }));
229
+ // return div;
230
+ //},
231
+ //
232
+ //edit_billing_address: function()
233
+ //{
234
+ // var that = this;
235
+ // var sa = that.invoice.billing_address;
236
+ // if (!sa) sa = { id: 1 };
237
+ // var table = $('<table/>').addClass('billing_address')
238
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
239
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
240
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
241
+ // ))))
242
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
243
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
244
+ // ))))
245
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
246
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
247
+ // ))))
248
+ // .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
249
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
250
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
251
+ // .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
252
+ // ))));
253
+ // $('#billing_address').empty()
254
+ // .append(table)
255
+ // .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
256
+ // var a = $(this);
257
+ // that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
258
+ // }));
259
+ //
260
+ // new ModelBinder({
261
+ // name: 'BillingAddress',
262
+ // id: sa.id,
263
+ // update_url: '/my-account/invoices/' + that.invoice.id + '/billing-address',
264
+ // authenticity_token: that.authenticity_token,
265
+ // attributes: [
266
+ // { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
267
+ // { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
268
+ // { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
269
+ // { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
270
+ // { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
271
+ // { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
272
+ // { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
273
+ // ]
274
+ // });
275
+ //},
273
276
 
274
277
  // Show all the packages and the line items in each package
275
278
  packaged_line_items_table: function(table)
@@ -304,7 +307,7 @@ MyAccountInvoiceController.prototype = {
304
307
  unpackaged_line_items_table: function(table)
305
308
  {
306
309
  var that = this;
307
-
310
+
308
311
  var count = 0;
309
312
  var line_items = [];
310
313
  $.each(that.invoice.line_items, function(i, li) {
@@ -401,22 +404,23 @@ MyAccountInvoiceController.prototype = {
401
404
  summary_table: function(table)
402
405
  {
403
406
  var that = this;
404
- table.append($('<tr/>').append($('<th/>').attr('colspan', '5').addClass('totals_header').html('Totals')));
405
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.invoice.subtotal ))));
406
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Tax' )).append($('<td/>').attr('align', 'right').attr('id', 'tax' ).html(curr(that.invoice.tax ))));
407
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.invoice.shipping ))));
408
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Handling' )).append($('<td/>').attr('align', 'right').attr('id', 'handling').html(curr(that.invoice.handling ))));
407
+ var requires_shipping = that.invoice_requires_shipping();
408
+ table.append($('<tr/>').append($('<th/>').attr('colspan', requires_shipping ? '6' : '5').addClass('totals_header').html('Totals')));
409
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.invoice.subtotal ))));
410
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Tax' )).append($('<td/>').attr('align', 'right').attr('id', 'tax' ).html(curr(that.invoice.tax ))));
411
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.invoice.shipping ))));
412
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Handling' )).append($('<td/>').attr('align', 'right').attr('id', 'handling').html(curr(that.invoice.handling ))));
409
413
  if (that.invoice.discounts)
410
414
  {
411
415
  $.each(that.invoice.discounts, function(i, d) {
412
416
  table.append($('<tr/>').addClass('totals_row')
413
- .append($('<td/>').attr('colspan', '4').attr('align', 'right').append(' "' + d.gift_card.code + '" Discount'))
417
+ .append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').append(' "' + d.gift_card.code + '" Discount'))
414
418
  .append($('<td/>').attr('align', 'right').html(curr(d.amount)))
415
419
  );
416
420
  });
417
421
  }
418
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').attr('id', 'custom_discount').html(curr(that.invoice.custom_discount))));
419
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total' ).html(curr(that.invoice.total))));
422
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').attr('id', 'custom_discount').html(curr(that.invoice.custom_discount))));
423
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', requires_shipping ? '5' : '4').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total' ).html(curr(that.invoice.total))));
420
424
  },
421
425
 
422
426
  /****************************************************************************/
@@ -479,6 +483,16 @@ MyAccountInvoiceController.prototype = {
479
483
  return needs_shipping;
480
484
  },
481
485
 
486
+ invoice_requires_shipping: function()
487
+ {
488
+ var that = this;
489
+ var requires = false;
490
+ $.each(that.invoice.line_items, function(i, li) {
491
+ if (li.requires_shipping && !li.downloadable)
492
+ requires = true;
493
+ });
494
+ return requires;
495
+ }
482
496
  };
483
497
 
484
498
  function relay_handler(resp)
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.38'
2
+ VERSION = '0.8.39'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.38
4
+ version: 0.8.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry