caboose-cms 0.7.85 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/{admin_edit_order.js → admin_edit_invoice.js} +332 -189
- data/app/assets/javascripts/caboose/cart.js +15 -15
- data/app/assets/javascripts/caboose/cart_old.js +2 -2
- data/app/assets/javascripts/caboose/checkout/authnet_payment_method_controller.js +120 -0
- data/app/assets/javascripts/caboose/checkout/billing_address_controller.js +85 -0
- data/app/assets/javascripts/caboose/checkout/cart_controller.js +257 -0
- data/app/assets/javascripts/caboose/checkout/checkout_controller.js +258 -0
- data/app/assets/javascripts/caboose/checkout/gift_cards_controller.js +57 -0
- data/app/assets/javascripts/caboose/checkout/shipping_address_controller.js +86 -0
- data/app/assets/javascripts/caboose/checkout/shipping_method_controller.js +121 -0
- data/app/assets/javascripts/caboose/checkout/stripe_payment_method_controller.js +155 -0
- data/app/assets/javascripts/caboose/checkout_login_register.js +2 -2
- data/app/assets/javascripts/caboose/checkout_module.js +8 -8
- data/app/assets/javascripts/caboose/checkout_old.js +151 -0
- data/app/assets/javascripts/caboose/{checkout_payment.js → checkout_payment_authnet.js} +1 -1
- data/app/assets/javascripts/caboose/checkout_payment_stripe.js +212 -0
- data/app/assets/javascripts/caboose/checkout_shipping.js +1 -1
- data/app/assets/javascripts/caboose/jquery.payment.js +1 -0
- data/app/assets/javascripts/caboose/model/attribute.js +3 -2
- data/app/assets/javascripts/caboose/model/bound_control.js +56 -14
- data/app/assets/javascripts/caboose/model/bound_select.js +9 -11
- data/app/assets/javascripts/caboose/model/bound_select_simple.js +215 -0
- data/app/assets/javascripts/caboose/model/bound_text.js +7 -8
- data/app/assets/javascripts/caboose/{my_account_edit_order.js → my_account_edit_invoice.js} +55 -55
- data/app/assets/javascripts/caboose/united_states.js +65 -0
- data/app/assets/stylesheets/caboose/{my_account_edit_order.css.scss → my_account_edit_invoice.css.scss} +1 -1
- data/app/assets/templates/caboose/cart/line_items.jst.ejs +3 -3
- data/app/assets/templates/caboose/checkout/line_items.jst.ejs +7 -7
- data/app/controllers/caboose/ab_options_controller.rb +4 -4
- data/app/controllers/caboose/ab_variants_controller.rb +5 -5
- data/app/controllers/caboose/admin_controller.rb +0 -6
- data/app/controllers/caboose/application_controller.rb +16 -15
- data/app/controllers/caboose/billing_addresses_controller.rb +22 -22
- data/app/controllers/caboose/block_type_sources_controller.rb +8 -8
- data/app/controllers/caboose/block_types_controller.rb +2 -42
- data/app/controllers/caboose/blocks_controller.rb +26 -26
- data/app/controllers/caboose/calendars_controller.rb +5 -5
- data/app/controllers/caboose/cart_controller.rb +55 -36
- data/app/controllers/caboose/categories_controller.rb +78 -76
- data/app/controllers/caboose/checkout_controller.rb +313 -340
- data/app/controllers/caboose/checkout_controller_bak.rb +620 -0
- data/app/controllers/caboose/domains_controller.rb +5 -5
- data/app/controllers/caboose/event_groups_controller.rb +26 -4
- data/app/controllers/caboose/events_controller.rb +7 -6
- data/app/controllers/caboose/fonts_controller.rb +2 -2
- data/app/controllers/caboose/gift_cards_controller.rb +113 -139
- data/app/controllers/caboose/google_spreadsheets_controller.rb +1 -1
- data/app/controllers/caboose/{order_packages_controller.rb → invoice_packages_controller.rb} +49 -49
- data/app/controllers/caboose/{order_reports_controller.rb → invoice_reports_controller.rb} +11 -13
- data/app/controllers/caboose/invoice_transactions_controller.rb +35 -0
- data/app/controllers/caboose/invoices_controller.rb +328 -0
- data/app/controllers/caboose/line_items_controller.rb +35 -34
- data/app/controllers/caboose/login_controller.rb +7 -7
- data/app/controllers/caboose/login_logs_controller.rb +4 -4
- data/app/controllers/caboose/logout_controller.rb +3 -1
- data/app/controllers/caboose/media_categories_controller.rb +9 -9
- data/app/controllers/caboose/media_controller.rb +21 -46
- data/app/controllers/caboose/modal_controller.rb +4 -3
- data/app/controllers/caboose/modification_values_controller.rb +6 -6
- data/app/controllers/caboose/modifications_controller.rb +7 -6
- data/app/controllers/caboose/my_account_controller.rb +2 -2
- data/app/controllers/caboose/my_account_invoices_controller.rb +166 -0
- data/app/controllers/caboose/my_account_line_items_controller.rb +15 -13
- data/app/controllers/caboose/page_custom_fields_controller.rb +9 -8
- data/app/controllers/caboose/page_permissions_controller.rb +3 -3
- data/app/controllers/caboose/pages_controller.rb +132 -135
- data/app/controllers/caboose/permissions_controller.rb +8 -7
- data/app/controllers/caboose/post_categories_controller.rb +22 -7
- data/app/controllers/caboose/post_custom_fields_controller.rb +9 -8
- data/app/controllers/caboose/posts_controller.rb +35 -43
- data/app/controllers/caboose/product_images_controller.rb +5 -5
- data/app/controllers/caboose/products_controller.rb +53 -47
- data/app/controllers/caboose/redirects_controller.rb +7 -7
- data/app/controllers/caboose/register_controller.rb +2 -2
- data/app/controllers/caboose/retargeting_controller.rb +2 -61
- data/app/controllers/caboose/reviews_controller.rb +1 -0
- data/app/controllers/caboose/roles_controller.rb +10 -9
- data/app/controllers/caboose/settings_controller.rb +9 -7
- data/app/controllers/caboose/shipping_addresses_controller.rb +18 -18
- data/app/controllers/caboose/shipping_packages_controller.rb +24 -21
- data/app/controllers/caboose/sites_controller.rb +35 -25
- data/app/controllers/caboose/smtp_controller.rb +3 -3
- data/app/controllers/caboose/sns_controller.rb +6 -6
- data/app/controllers/caboose/social_controller.rb +5 -6
- data/app/controllers/caboose/stackable_groups_controller.rb +10 -8
- data/app/controllers/caboose/station_controller.rb +3 -3
- data/app/controllers/caboose/store_controller.rb +93 -87
- data/app/controllers/caboose/subscriptions_controller.rb +153 -0
- data/app/controllers/caboose/users_controller.rb +25 -22
- data/app/controllers/caboose/variants_controller.rb +72 -93
- data/app/controllers/caboose/vendors_controller.rb +35 -32
- data/app/mailers/caboose/{orders_mailer.rb → invoices_mailer.rb} +21 -21
- data/app/mailers/caboose/login_mailer.rb +3 -3
- data/app/models/caboose/authnet.rb +295 -195
- data/app/models/caboose/comment_routes.rb +68 -41
- data/app/models/caboose/core_plugin.rb +1 -1
- data/app/models/caboose/discount.rb +14 -3
- data/app/models/caboose/domain_constraint.rb +11 -3
- data/app/models/caboose/gift_card.rb +8 -8
- data/app/models/caboose/invoice.rb +706 -0
- data/app/models/caboose/invoice_discount.rb +10 -0
- data/app/models/caboose/invoice_package.rb +76 -0
- data/app/models/caboose/{order_package_calculator.rb → invoice_package_calculator.rb} +20 -20
- data/app/models/caboose/{order_pdf.rb → invoice_pdf.rb} +30 -30
- data/app/models/caboose/{order_reporter.rb → invoice_reporter.rb} +5 -5
- data/app/models/caboose/invoice_transaction.rb +169 -0
- data/app/models/caboose/line_item.rb +11 -8
- data/app/models/caboose/payment_processors/authorizenet.rb +15 -15
- data/app/models/caboose/payment_processors/base.rb +3 -3
- data/app/models/caboose/{pending_orders_pdf.rb → pending_invoices_pdf.rb} +31 -31
- data/app/models/caboose/product.rb +2 -4
- data/app/models/caboose/schema.rb +159 -111
- data/app/models/caboose/shipping_calculator.rb +41 -139
- data/app/models/caboose/smtp_config.rb +2 -1
- data/app/models/caboose/store_config.rb +7 -7
- data/app/models/caboose/subscription.rb +32 -0
- data/app/models/caboose/tax_calculator.rb +36 -36
- data/app/models/caboose/user.rb +6 -0
- data/app/models/caboose/user_subscription.rb +142 -0
- data/app/models/caboose/wish_list.rb +14 -0
- data/app/models/caboose/wish_list_line_item.rb +13 -0
- data/app/views/caboose/blocks/_products.html.erb +10 -13
- data/app/views/caboose/checkout/_address_form.html.erb +14 -14
- data/app/views/caboose/checkout/_billing_form.html.erb +3 -3
- data/app/views/caboose/checkout/_cart.html.erb +7 -7
- data/app/views/caboose/checkout/_cart_old.html.erb +9 -9
- data/app/views/caboose/checkout/_confirm.html.erb +9 -9
- data/app/views/caboose/checkout/_order_discount.html.erb +3 -3
- data/app/views/caboose/checkout/_shipping_address.html.erb +1 -1
- data/app/views/caboose/checkout/_shipping_method.html.erb +1 -1
- data/app/views/caboose/checkout/addresses.html.erb +10 -10
- data/app/views/caboose/checkout/authnet.html.erb +34 -0
- data/app/views/caboose/checkout/authnet_response_handler.html.erb +3 -0
- data/app/views/caboose/checkout/checkout.html.erb +100 -0
- data/app/views/caboose/checkout/confirm_without_payment.html.erb +6 -6
- data/app/views/caboose/checkout/discount.html.erb +1 -1
- data/app/views/caboose/checkout/index.html.erb +4 -4
- data/app/views/caboose/checkout/payment_authnet.html.erb +140 -0
- data/app/views/caboose/checkout/payment_stripe.html.erb +95 -0
- data/app/views/caboose/checkout/shipping.html.erb +4 -4
- data/app/views/caboose/checkout/thanks.html.erb +3 -3
- data/app/views/caboose/gift_cards/admin_edit.html.erb +19 -19
- data/app/views/caboose/gift_cards/admin_index.html.erb +9 -9
- data/app/views/caboose/{orders → invoices}/_admin_footer.html.erb +0 -0
- data/app/views/caboose/{orders → invoices}/_admin_header.html.erb +0 -0
- data/app/views/caboose/{orders/_quickbooks_order.html.erb → invoices/_quickbooks_invoice.html.erb} +0 -0
- data/app/views/caboose/{orders → invoices}/admin_city_report.html.erb +1 -1
- data/app/views/caboose/invoices/admin_delete_form.html.erb +18 -0
- data/app/views/caboose/{orders → invoices}/admin_edit.html.erb +14 -14
- data/app/views/caboose/{orders → invoices}/admin_index.html.erb +24 -24
- data/app/views/caboose/{orders → invoices}/admin_invalid_order.html.erb +2 -2
- data/app/views/caboose/{orders → invoices}/admin_new.html.erb +7 -7
- data/app/views/caboose/{orders → invoices}/admin_print.html.erb +15 -15
- data/app/views/caboose/{orders → invoices}/admin_summary_report.html.erb +4 -4
- data/app/views/caboose/{orders_mailer/customer_new_order.html.erb → invoices_mailer/customer_new_invoice.html.erb} +21 -21
- data/app/views/caboose/invoices_mailer/customer_payment_authorization.html.erb +5 -0
- data/app/views/caboose/{orders_mailer → invoices_mailer}/customer_status_updated.html.erb +22 -22
- data/app/views/caboose/{orders_mailer/fulfillment_new_order.html.erb → invoices_mailer/fulfillment_new_invoice.html.erb} +23 -23
- data/app/views/caboose/{orders_mailer/shipping_order_ready.html.erb → invoices_mailer/shipping_invoice_ready.html.erb} +0 -0
- data/app/views/caboose/{orders_mailer → invoices_mailer}/test_email.html.erb +0 -0
- data/app/views/caboose/line_items/admin_new.html.erb +1 -1
- data/app/views/caboose/login_mailer/forgot_password_email.html.erb +2 -3
- data/app/views/caboose/my_account/index.html.erb +1 -1
- data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_relay.html.erb +0 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_response.html.erb +0 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/edit.html.erb +9 -9
- data/app/views/caboose/my_account_invoices/index.html.erb +36 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/payment_form.html.erb +10 -10
- data/app/views/caboose/post_categories/admin_index.html.erb +1 -1
- data/app/views/caboose/sites/admin_edit.html.erb +1 -1
- data/app/views/caboose/store/admin_edit_general.html.erb +5 -3
- data/app/views/caboose/store/admin_edit_packages.html.erb +6 -6
- data/app/views/caboose/store/admin_edit_shipping.html.erb +3 -3
- data/app/views/caboose/store/admin_edit_tax.html.erb +1 -1
- data/app/views/caboose/subscriptions/admin_edit.html.erb +82 -0
- data/app/views/caboose/subscriptions/admin_index.html.erb +45 -0
- data/config/routes.rb +1 -759
- data/config/routes_old.rb +759 -0
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +41 -15
- metadata +101 -61
- data/app/controllers/caboose/my_account_orders_controller.rb +0 -165
- data/app/controllers/caboose/orders_controller.rb +0 -310
- data/app/models/caboose/order.rb +0 -479
- data/app/models/caboose/order_discount.rb +0 -10
- data/app/models/caboose/order_package.rb +0 -133
- data/app/models/caboose/order_transaction.rb +0 -41
- data/app/models/caboose/payment_processors/payscape.rb +0 -94
- data/app/views/caboose/checkout/payment.html.erb +0 -146
- data/app/views/caboose/my_account_orders/index.html.erb +0 -36
- data/app/views/caboose/orders/admin_delete_form.html.erb +0 -21
- data/app/views/caboose/orders_mailer/customer_payment_authorization.html.erb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f13467e0292ffa5dc2b33fb4146f332c90d5d2d7
|
4
|
+
data.tar.gz: df91b598feb3cbc02ef15b850d34341d6f916f88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36c2cbb7516bfb4a3a691a798f98628bbb66462eae11872433dd19238608e8766fff6112875f9508bedeabf319b45b28da76c7c5e028562f4432658bc4557e0
|
7
|
+
data.tar.gz: 3e90010701da42e89a7952b54e42cbe9b44a5bf5356d049cfeedee9c117c18fec989391362906871e9ff18999033207c2f13d400fb5eace2859cca108cbe5165
|
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
var
|
2
|
+
var InvoiceController = function(params) { this.init(params); }
|
3
3
|
|
4
|
-
|
4
|
+
InvoiceController.prototype = {
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
invoice_id: false,
|
7
|
+
invoice: false,
|
8
8
|
authenticity_token: false,
|
9
9
|
store_config: false,
|
10
10
|
|
@@ -33,21 +33,25 @@ OrderController.prototype = {
|
|
33
33
|
refresh: function(after)
|
34
34
|
{
|
35
35
|
var that = this;
|
36
|
-
that.
|
37
|
-
$('#
|
36
|
+
that.refresh_invoice(function() {
|
37
|
+
$('#invoice_table').html("<p class='loading'>Getting invoice...</p>");
|
38
38
|
that.print();
|
39
39
|
that.make_editable();
|
40
40
|
if (after) after();
|
41
41
|
});
|
42
42
|
},
|
43
43
|
|
44
|
-
|
44
|
+
refresh_invoice: function(after)
|
45
45
|
{
|
46
46
|
var that = this;
|
47
47
|
$.ajax({
|
48
|
-
url: '/admin/
|
49
|
-
success: function(
|
50
|
-
that.
|
48
|
+
url: '/admin/invoices/' + that.invoice_id + '/json',
|
49
|
+
success: function(invoice) {
|
50
|
+
that.invoice = invoice;
|
51
|
+
$.each(that.invoice.invoice_transactions, function(i, t) {
|
52
|
+
t.amount = parseFloat(t.amount);
|
53
|
+
t.amount_refunded = t.amount_refunded == null || isNaN(t.amount_refunded) ? 0.00 : parseFloat(t.amount_refunded);
|
54
|
+
});
|
51
55
|
that.refresh_numbers();
|
52
56
|
if (after) after();
|
53
57
|
}
|
@@ -57,10 +61,10 @@ OrderController.prototype = {
|
|
57
61
|
refresh_numbers: function()
|
58
62
|
{
|
59
63
|
var that = this;
|
60
|
-
$('#subtotal').html(curr(that.
|
61
|
-
$('#shipping').html(curr(that.
|
62
|
-
$('#total' ).html(curr(that.
|
63
|
-
$.each(that.
|
64
|
+
$('#subtotal').html(curr(that.invoice.subtotal));
|
65
|
+
$('#shipping').html(curr(that.invoice.shipping));
|
66
|
+
$('#total' ).html(curr(that.invoice.total ));
|
67
|
+
$.each(that.invoice.line_items, function(i, li) {
|
64
68
|
$('#li_' + li.id + '_subtotal').html(curr(li.subtotal));
|
65
69
|
});
|
66
70
|
},
|
@@ -68,43 +72,44 @@ OrderController.prototype = {
|
|
68
72
|
make_editable: function()
|
69
73
|
{
|
70
74
|
var that = this;
|
71
|
-
$.each(that.
|
75
|
+
$.each(that.invoice.invoice_packages, function(i, op) {
|
72
76
|
new ModelBinder({
|
73
|
-
name: '
|
77
|
+
name: 'InvoicePackage',
|
74
78
|
id: op.id,
|
75
|
-
update_url: '/admin/
|
79
|
+
update_url: '/admin/invoices/' + op.invoice_id + '/packages/' + op.id,
|
76
80
|
authenticity_token: that.authenticity_token,
|
77
81
|
attributes: [
|
78
|
-
{ name: 'status' , nice_name: 'Status' , type: 'select' , value: op.status , width: 300, fixed_placeholder: true , options_url: '/admin/
|
82
|
+
{ name: 'status' , nice_name: 'Status' , type: 'select' , value: op.status , width: 300, fixed_placeholder: true , options_url: '/admin/invoices/line-items/status-options' },
|
79
83
|
{ name: 'package_method' , nice_name: 'Package/Method' , type: 'select' , value: op.shipping_package_id + '_' + op.shipping_method_id , width: 300, fixed_placeholder: false, options_url: '/admin/shipping-packages/package-method-options' },
|
80
84
|
{ name: 'tracking_number' , nice_name: 'Tracking Number' , type: 'text' , value: op.tracking_number , width: 300, fixed_placeholder: true, align: 'right' },
|
81
|
-
{ name: 'total' , nice_name: 'Shipping Total' , type: 'text' , value: curr(op.total) , width: 300, fixed_placeholder: true, align: 'right' , after_update: function() { that.
|
85
|
+
{ name: 'total' , nice_name: 'Shipping Total' , type: 'text' , value: curr(op.total) , width: 300, fixed_placeholder: true, align: 'right' , after_update: function() { that.refresh_invoice(); }}
|
82
86
|
]
|
83
87
|
});
|
84
88
|
});
|
85
|
-
$.each(that.
|
89
|
+
$.each(that.invoice.line_items, function(i, li) {
|
86
90
|
new ModelBinder({
|
87
91
|
name: 'Lineitem',
|
88
92
|
id: li.id,
|
89
|
-
update_url: '/admin/
|
93
|
+
update_url: '/admin/invoices/' + li.invoice_id + '/line-items/' + li.id,
|
90
94
|
authenticity_token: that.authenticity_token,
|
91
95
|
attributes: [
|
92
|
-
{ name: 'status' , nice_name: 'Status' , type: 'select' , align: 'left' , value: li.status , text: li.status, width: 150, fixed_placeholder: false, options_url: '/admin/
|
96
|
+
{ name: 'status' , nice_name: 'Status' , type: 'select' , align: 'left' , value: li.status , text: li.status, width: 150, fixed_placeholder: false, options_url: '/admin/invoices/line-items/status-options' },
|
93
97
|
{ name: 'tracking_number' , nice_name: 'Tracking Number' , type: 'text' , align: 'left' , value: li.tracking_number , width: 200, fixed_placeholder: false },
|
94
|
-
{ name: 'quantity' , nice_name: 'Quantity' , type: 'text' , align: 'right', value: li.quantity , width: 75, fixed_placeholder: false, after_update: function() { that.
|
98
|
+
{ name: 'quantity' , nice_name: 'Quantity' , type: 'text' , align: 'right', value: li.quantity , width: 75, fixed_placeholder: false, after_update: function() { that.refresh_invoice(); } }
|
95
99
|
]
|
96
100
|
});
|
97
101
|
});
|
98
102
|
new ModelBinder({
|
99
|
-
name: '
|
100
|
-
id: that.
|
101
|
-
update_url: '/admin/
|
103
|
+
name: 'Invoice',
|
104
|
+
id: that.invoice.id,
|
105
|
+
update_url: '/admin/invoices/' + that.invoice.id,
|
102
106
|
authenticity_token: that.authenticity_token,
|
103
107
|
attributes: [
|
104
|
-
{ name: 'status' , nice_name: 'Status'
|
105
|
-
{ name: '
|
106
|
-
{ name: '
|
107
|
-
{ name: '
|
108
|
+
{ name: 'status' , nice_name: 'Status' , type: 'select', value: that.invoice.status , width: 100, fixed_placeholder: false, options_url: '/admin/invoices/status-options' },
|
109
|
+
{ name: 'payment_terms' , nice_name: 'Terms' , type: 'select', value: that.invoice.payment_terms , width: 200, fixed_placeholder: true , options_url: '/admin/invoices/payment-terms-options' },
|
110
|
+
{ name: 'tax' , nice_name: 'Tax' , type: 'text' , value: curr(that.invoice.tax) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_invoice(); }},
|
111
|
+
{ name: 'handling' , nice_name: 'Handling' , type: 'text' , value: curr(that.invoice.handling) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_invoice(); }},
|
112
|
+
{ name: 'custom_discount', nice_name: 'Discount' , type: 'text' , value: curr(that.invoice.custom_discount) , width: 100, fixed_placeholder: false, align: 'right' , after_update: function() { that.refresh_invoice(); }}
|
108
113
|
]
|
109
114
|
});
|
110
115
|
},
|
@@ -112,23 +117,23 @@ OrderController.prototype = {
|
|
112
117
|
assign_to_package_form: function(li_id)
|
113
118
|
{
|
114
119
|
var that = this;
|
115
|
-
if (!that.
|
116
|
-
that.
|
117
|
-
if (that.
|
120
|
+
if (!that.invoice.invoice_packages)
|
121
|
+
that.invoice.invoice_packages = [];
|
122
|
+
if (that.invoice.invoice_packages.length == 0)
|
118
123
|
{
|
119
124
|
that.assign_to_new_package_form(li_id);
|
120
125
|
return;
|
121
126
|
}
|
122
127
|
|
123
|
-
var select = $('<select/>').attr('id', '
|
124
|
-
var
|
125
|
-
if (
|
128
|
+
var select = $('<select/>').attr('id', 'invoice_package_id').css('width', '300px').change(function(e) {
|
129
|
+
var invoice_package_id = $(this).val();
|
130
|
+
if (invoice_package_id == -1)
|
126
131
|
that.assign_to_new_package_form(li_id);
|
127
132
|
else
|
128
|
-
that.assign_to_package(li_id,
|
133
|
+
that.assign_to_package(li_id, invoice_package_id);
|
129
134
|
});
|
130
135
|
select.append($('<option/>').val(-1).html('-- Select a package --'));
|
131
|
-
$.each(that.
|
136
|
+
$.each(that.invoice.invoice_packages, function(i, op) {
|
132
137
|
var sp = op.shipping_package;
|
133
138
|
var sm = op.shipping_method;
|
134
139
|
var name = [];
|
@@ -155,10 +160,10 @@ OrderController.prototype = {
|
|
155
160
|
var select = $('<select/>')
|
156
161
|
.attr('id', 'package_id')
|
157
162
|
.css('width', '400px')
|
158
|
-
.change(function(e) { // Create the new
|
163
|
+
.change(function(e) { // Create the new invoice package
|
159
164
|
var arr = $(this).val().split('_');
|
160
165
|
$.ajax({
|
161
|
-
url: '/admin/
|
166
|
+
url: '/admin/invoices/' + that.invoice.id + '/packages',
|
162
167
|
type: 'post',
|
163
168
|
data: { shipping_package_id: arr[0], shipping_method_id: arr[1] },
|
164
169
|
success: function(resp) {
|
@@ -188,13 +193,13 @@ OrderController.prototype = {
|
|
188
193
|
});
|
189
194
|
},
|
190
195
|
|
191
|
-
assign_to_package: function(li_id,
|
196
|
+
assign_to_package: function(li_id, invoice_package_id)
|
192
197
|
{
|
193
198
|
var that = this;
|
194
199
|
$.ajax({
|
195
|
-
url: '/admin/
|
200
|
+
url: '/admin/invoices/' + that.invoice.id + '/line-items/' + li_id,
|
196
201
|
type: 'put',
|
197
|
-
data: {
|
202
|
+
data: { invoice_package_id: invoice_package_id },
|
198
203
|
success: function(resp) {
|
199
204
|
if (resp.error) $('#assign_to_package_' + li_id).html("<p class='note error'>" + resp.error + "</p>");
|
200
205
|
else that.refresh();
|
@@ -206,9 +211,9 @@ OrderController.prototype = {
|
|
206
211
|
{
|
207
212
|
var that = this;
|
208
213
|
$.ajax({
|
209
|
-
url: '/admin/
|
214
|
+
url: '/admin/invoices/' + that.invoice.id + '/line-items/' + li_id,
|
210
215
|
type: 'put',
|
211
|
-
data: {
|
216
|
+
data: { invoice_package_id: -1 },
|
212
217
|
success: function(resp) {
|
213
218
|
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
214
219
|
else that.refresh();
|
@@ -218,18 +223,18 @@ OrderController.prototype = {
|
|
218
223
|
|
219
224
|
/******************************************************************************/
|
220
225
|
|
221
|
-
|
226
|
+
print_invoice: function()
|
222
227
|
{
|
223
228
|
var that = this;
|
224
|
-
window.open('/admin/
|
229
|
+
window.open('/admin/invoices/' + that.invoice.id + '/print');
|
225
230
|
},
|
226
231
|
|
227
|
-
|
232
|
+
line_items_for_invoice_package: function(invoice_package_id)
|
228
233
|
{
|
229
234
|
var that = this;
|
230
235
|
var line_items = [];
|
231
|
-
$.each(that.
|
232
|
-
if (li.
|
236
|
+
$.each(that.invoice.line_items, function(i, li) {
|
237
|
+
if (li.invoice_package_id == invoice_package_id)
|
233
238
|
line_items.push(li);
|
234
239
|
});
|
235
240
|
return line_items;
|
@@ -243,10 +248,10 @@ OrderController.prototype = {
|
|
243
248
|
$('#overview_table').empty().append(table).append($('<br />'));
|
244
249
|
|
245
250
|
table = $('<table/>').addClass('data').css('width', '100%');
|
246
|
-
that.
|
251
|
+
that.invoice_packages_table(table);
|
247
252
|
that.unassigned_line_items_table(table);
|
248
253
|
that.summary_table(table);
|
249
|
-
$('#
|
254
|
+
$('#invoice_table').empty().append(table);
|
250
255
|
|
251
256
|
that.button_controls();
|
252
257
|
},
|
@@ -255,34 +260,13 @@ OrderController.prototype = {
|
|
255
260
|
{
|
256
261
|
var that = this;
|
257
262
|
|
258
|
-
var
|
259
|
-
if (that.order.order_transactions.length > 0)
|
260
|
-
{
|
261
|
-
var transactions_table = $('<table/>').addClass('data');
|
262
|
-
$.each(that.order.order_transactions, function(i, ot) {
|
263
|
-
var d = new Date(ot.date_processed);
|
264
|
-
var h = d.getHours();
|
265
|
-
var ampm = 'am';
|
266
|
-
if (h >= 12) ampm = 'pm';
|
267
|
-
if (h > 12) h = h - 12;
|
268
|
-
d = '' + (d.getMonth()+1) + '/' + d.getDate() + '/' + d.getYear() + '<br/>' + h + ':' + d.getMinutes() + ' ' + ampm;
|
269
|
-
transactions_table.append($('<tr/>')
|
270
|
-
.append($('<td/>').html(d ))
|
271
|
-
.append($('<td/>').html(ot.transaction_type ))
|
272
|
-
.append($('<td/>').html(curr(ot.amount) ))
|
273
|
-
.append($('<td/>').html(ot.transaction_id ))
|
274
|
-
.append($('<td/>').html(ot.success ? 'Success' : 'Fail'))
|
275
|
-
);
|
276
|
-
});
|
277
|
-
fstatus.append(transactions_table);
|
278
|
-
}
|
279
|
-
|
263
|
+
var transactions = that.transactions_table();
|
280
264
|
var table = $('<table/>').addClass('data');
|
281
265
|
table.append($('<tr/>')
|
282
266
|
.append($('<th/>').html('Customer'))
|
283
267
|
.append($('<th/>').html('Shipping Address'))
|
284
268
|
.append($('<th/>').html('Billing Address'))
|
285
|
-
.append($('<th/>').html('
|
269
|
+
.append($('<th/>').html('Invoice Status'))
|
286
270
|
.append($('<th/>').html('Payment Status'))
|
287
271
|
);
|
288
272
|
table.append($('<tr/>')
|
@@ -290,7 +274,7 @@ OrderController.prototype = {
|
|
290
274
|
.append($('<div/>').attr('id', 'customer').append(that.noneditable_customer(true)))
|
291
275
|
.append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
|
292
276
|
var a = $(this);
|
293
|
-
that.
|
277
|
+
that.refresh_invoice(function() {
|
294
278
|
if (a.html() == 'Edit') { that.edit_customer(); a.html('Finished'); }
|
295
279
|
else { that.noneditable_customer(); a.html('Edit'); }
|
296
280
|
});
|
@@ -298,8 +282,11 @@ OrderController.prototype = {
|
|
298
282
|
)
|
299
283
|
.append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(that.noneditable_shipping_address()))
|
300
284
|
.append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
|
301
|
-
.append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', '
|
302
|
-
.append($('<td/>').attr('valign', 'top')
|
285
|
+
.append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_status')))
|
286
|
+
.append($('<td/>').attr('valign', 'top')
|
287
|
+
.append($('<div/>').attr('id', 'invoice_' + that.invoice.id + '_payment_terms'))
|
288
|
+
.append($('<div/>').attr('id', 'transactions').attr('align', 'center').append(transactions))
|
289
|
+
)
|
303
290
|
);
|
304
291
|
return table;
|
305
292
|
},
|
@@ -307,7 +294,7 @@ OrderController.prototype = {
|
|
307
294
|
noneditable_customer: function(return_element)
|
308
295
|
{
|
309
296
|
var that = this;
|
310
|
-
c = that.
|
297
|
+
c = that.invoice.customer;
|
311
298
|
str = '';
|
312
299
|
if (c)
|
313
300
|
{
|
@@ -325,16 +312,16 @@ OrderController.prototype = {
|
|
325
312
|
edit_customer: function()
|
326
313
|
{
|
327
314
|
var that = this;
|
328
|
-
var div = $('<div/>').attr('id', '
|
315
|
+
var div = $('<div/>').attr('id', 'invoice_' + that.invoice.id + '_customer_id');
|
329
316
|
$('#customer').empty().append(div);
|
330
317
|
|
331
318
|
new ModelBinder({
|
332
|
-
name: '
|
333
|
-
id: that.
|
334
|
-
update_url: '/admin/
|
319
|
+
name: 'Invoice',
|
320
|
+
id: that.invoice.id,
|
321
|
+
update_url: '/admin/invoices/' + that.invoice.id,
|
335
322
|
authenticity_token: that.authenticity_token,
|
336
323
|
attributes: [
|
337
|
-
{ name: 'customer_id', nice_name: 'Customer', type: 'select', value: that.
|
324
|
+
{ name: 'customer_id', nice_name: 'Customer', type: 'select', value: that.invoice.customer_id, width: 150, fixed_placeholder: false, options_url: '/admin/users/options' }
|
338
325
|
]
|
339
326
|
});
|
340
327
|
},
|
@@ -345,7 +332,7 @@ OrderController.prototype = {
|
|
345
332
|
var div = $('<div/>');
|
346
333
|
if (that.has_shippable_items())
|
347
334
|
{
|
348
|
-
var sa = that.
|
335
|
+
var sa = that.invoice.shipping_address;
|
349
336
|
str = '';
|
350
337
|
str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
|
351
338
|
str += (sa.last_name ? sa.last_name : '[Empty last name]');
|
@@ -356,12 +343,12 @@ OrderController.prototype = {
|
|
356
343
|
div.append($('<div/>').attr('id', 'shipping_address').append(str));
|
357
344
|
div.append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
|
358
345
|
var a = $(this);
|
359
|
-
that.
|
346
|
+
that.refresh_invoice(function() { that.edit_shipping_address(); });
|
360
347
|
}));
|
361
348
|
}
|
362
349
|
else
|
363
350
|
{
|
364
|
-
div.append("This
|
351
|
+
div.append("This invoice does not require shipping.");
|
365
352
|
}
|
366
353
|
return div;
|
367
354
|
},
|
@@ -369,7 +356,7 @@ OrderController.prototype = {
|
|
369
356
|
edit_shipping_address: function()
|
370
357
|
{
|
371
358
|
var that = this;
|
372
|
-
var sa = that.
|
359
|
+
var sa = that.invoice.shipping_address;
|
373
360
|
var table = $('<table/>').addClass('shipping_address')
|
374
361
|
.append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
|
375
362
|
.append($('<td/>').append($('<div/>').attr('id', 'shippingaddress_' + sa.id + '_first_name')))
|
@@ -390,13 +377,13 @@ OrderController.prototype = {
|
|
390
377
|
.append(table)
|
391
378
|
.append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
|
392
379
|
var a = $(this);
|
393
|
-
that.
|
380
|
+
that.refresh_invoice(function() { $('#shipping_address').empty().append(that.noneditable_shipping_address()); });
|
394
381
|
}));
|
395
382
|
|
396
383
|
new ModelBinder({
|
397
384
|
name: 'ShippingAddress',
|
398
385
|
id: sa.id,
|
399
|
-
update_url: '/admin/
|
386
|
+
update_url: '/admin/invoices/' + that.invoice.id + '/shipping-address',
|
400
387
|
authenticity_token: that.authenticity_token,
|
401
388
|
attributes: [
|
402
389
|
{ name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
|
@@ -414,7 +401,7 @@ OrderController.prototype = {
|
|
414
401
|
{
|
415
402
|
var that = this;
|
416
403
|
|
417
|
-
var sa = that.
|
404
|
+
var sa = that.invoice.billing_address;
|
418
405
|
if (!sa) sa = {};
|
419
406
|
var str = '';
|
420
407
|
str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
|
@@ -428,7 +415,7 @@ OrderController.prototype = {
|
|
428
415
|
.append("<br />")
|
429
416
|
.append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
|
430
417
|
var a = $(this);
|
431
|
-
that.
|
418
|
+
that.refresh_invoice(function() { that.edit_billing_address(); });
|
432
419
|
}));
|
433
420
|
return div;
|
434
421
|
},
|
@@ -436,7 +423,7 @@ OrderController.prototype = {
|
|
436
423
|
edit_billing_address: function()
|
437
424
|
{
|
438
425
|
var that = this;
|
439
|
-
var sa = that.
|
426
|
+
var sa = that.invoice.billing_address;
|
440
427
|
if (!sa) sa = { id: 1 };
|
441
428
|
var table = $('<table/>').addClass('billing_address')
|
442
429
|
.append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
|
@@ -458,13 +445,13 @@ OrderController.prototype = {
|
|
458
445
|
.append(table)
|
459
446
|
.append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
|
460
447
|
var a = $(this);
|
461
|
-
that.
|
448
|
+
that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
|
462
449
|
}));
|
463
450
|
|
464
451
|
new ModelBinder({
|
465
452
|
name: 'BillingAddress',
|
466
453
|
id: sa.id,
|
467
|
-
update_url: '/admin/
|
454
|
+
update_url: '/admin/invoices/' + that.invoice.id + '/billing-address',
|
468
455
|
authenticity_token: that.authenticity_token,
|
469
456
|
attributes: [
|
470
457
|
{ name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
|
@@ -479,11 +466,11 @@ OrderController.prototype = {
|
|
479
466
|
},
|
480
467
|
|
481
468
|
// Show all the packages and the line items in each package
|
482
|
-
|
469
|
+
invoice_packages_table: function(table)
|
483
470
|
{
|
484
471
|
var that = this;
|
485
|
-
$.each(that.
|
486
|
-
var line_items = that.
|
472
|
+
$.each(that.invoice.invoice_packages, function(i, op) {
|
473
|
+
var line_items = that.line_items_for_invoice_package(op.id);
|
487
474
|
if (line_items && line_items.length > 0)
|
488
475
|
{
|
489
476
|
table.append($('<tr/>')
|
@@ -522,15 +509,15 @@ OrderController.prototype = {
|
|
522
509
|
)
|
523
510
|
.append($('<tr/>')
|
524
511
|
.append($('<td/>')
|
525
|
-
.append($('<div/>').attr('id', '
|
526
|
-
.append($('<div/>').attr('id', '
|
527
|
-
.append($('<div/>').attr('id', '
|
528
|
-
.append($('<div/>').attr('id', '
|
512
|
+
.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_package_method'))
|
513
|
+
.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_status'))
|
514
|
+
.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_tracking_number'))
|
515
|
+
.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_total'))
|
529
516
|
)
|
530
517
|
.append($('<td/>').attr('colspan', '5')
|
531
518
|
.append($('<p>')
|
532
519
|
.append("This package is empty. ")
|
533
|
-
.append($('<a/>').attr('href', '#').html('Delete Package').data('op_id', op.id).click(function(e) { e.preventDefault(); that.
|
520
|
+
.append($('<a/>').attr('href', '#').html('Delete Package').data('op_id', op.id).click(function(e) { e.preventDefault(); that.delete_invoice_package($(this).data('op_id')); }))
|
534
521
|
)
|
535
522
|
)
|
536
523
|
);
|
@@ -548,13 +535,13 @@ OrderController.prototype = {
|
|
548
535
|
});
|
549
536
|
|
550
537
|
var div = $('<div/>');
|
551
|
-
div.append($('<div/>').attr('id', '
|
552
|
-
div.append($('<div/>').attr('id', '
|
553
|
-
div.append($('<div/>').attr('id', '
|
554
|
-
div.append($('<div/>').attr('id', '
|
555
|
-
div.append($('<div/>').attr('id', '
|
556
|
-
div.append($('<a/>').attr('href','#').data('
|
557
|
-
div.append($('<div/>').attr('id', '
|
538
|
+
div.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_package_method'));
|
539
|
+
div.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_status'));
|
540
|
+
div.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_tracking_number'));
|
541
|
+
div.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_total'));
|
542
|
+
div.append($('<div/>').attr('id', 'invoicepackage_' + op.id + '_total_weight').html("Total weight: " + total_weight + " " + that.store_config.weight_unit));
|
543
|
+
div.append($('<a/>').attr('href','#').data('invoice_package_id', op.id).html('Recalculate').click(function(e) { e.preventDefault(); that.calculate_shipping($(this).data('invoice_package_id')); }));
|
544
|
+
div.append($('<div/>').attr('id', 'invoice_package_' + op.id + '_message'));
|
558
545
|
return div;
|
559
546
|
},
|
560
547
|
|
@@ -592,10 +579,10 @@ OrderController.prototype = {
|
|
592
579
|
}
|
593
580
|
var link = $('<a/>').attr('href', '#').html(name)
|
594
581
|
.data('li_id', li.id)
|
595
|
-
.data('
|
582
|
+
.data('invoice_package_id', li.invoice_package_id)
|
596
583
|
.click(function(e) {
|
597
584
|
e.preventDefault();
|
598
|
-
that.line_item_options($(this).data('li_id'), $(this).data('
|
585
|
+
that.line_item_options($(this).data('li_id'), $(this).data('invoice_package_id'));
|
599
586
|
});
|
600
587
|
return link;
|
601
588
|
},
|
@@ -610,15 +597,15 @@ OrderController.prototype = {
|
|
610
597
|
return div;
|
611
598
|
},
|
612
599
|
|
613
|
-
line_item_options: function(li_id,
|
600
|
+
line_item_options: function(li_id, invoice_package_id)
|
614
601
|
{
|
615
602
|
var that = this;
|
616
603
|
var ul = $('<ul/>').addClass('line_item_controls');
|
617
604
|
ul.append($('<li/>').append($('<a/>')
|
618
605
|
.html('View Product')
|
619
|
-
.attr('href', '/admin/
|
606
|
+
.attr('href', '/admin/invoices/' + that.invoice.id + '/line-items/' + li_id + '/highlight')
|
620
607
|
))
|
621
|
-
if (
|
608
|
+
if (invoice_package_id && invoice_package_id != -1)
|
622
609
|
{
|
623
610
|
ul.append($('<li/>').append($('<a/>')
|
624
611
|
.html('Remove from Package')
|
@@ -628,7 +615,7 @@ OrderController.prototype = {
|
|
628
615
|
));
|
629
616
|
}
|
630
617
|
ul.append($('<li/>').append($('<a/>')
|
631
|
-
.html('Remove from
|
618
|
+
.html('Remove from Invoice')
|
632
619
|
.attr('href', '#')
|
633
620
|
.data('li_id', li_id)
|
634
621
|
.click(function(e) { e.preventDefault(); that.delete_line_item($(this).data('li_id')); })
|
@@ -646,8 +633,8 @@ OrderController.prototype = {
|
|
646
633
|
var that = this;
|
647
634
|
|
648
635
|
var has_unassigned_line_items = false
|
649
|
-
$.each(that.
|
650
|
-
if (!li.
|
636
|
+
$.each(that.invoice.line_items, function(i, li) {
|
637
|
+
if (!li.invoice_package_id || li.invoice_package_id == -1)
|
651
638
|
{
|
652
639
|
has_unassigned_line_items = true;
|
653
640
|
return false;
|
@@ -665,8 +652,8 @@ OrderController.prototype = {
|
|
665
652
|
.append($('<th/>').html('Subtotal' ))
|
666
653
|
);
|
667
654
|
|
668
|
-
$.each(that.
|
669
|
-
if (li.
|
655
|
+
$.each(that.invoice.line_items, function(i, li) {
|
656
|
+
if (li.invoice_package_id && li.invoice_package_id != -1) return true;
|
670
657
|
|
671
658
|
var div = false;
|
672
659
|
|
@@ -700,24 +687,24 @@ OrderController.prototype = {
|
|
700
687
|
});
|
701
688
|
},
|
702
689
|
|
703
|
-
// Show the
|
690
|
+
// Show the invoice summary
|
704
691
|
summary_table: function(table)
|
705
692
|
{
|
706
693
|
var that = this;
|
707
|
-
if (that.
|
694
|
+
if (that.invoice.line_items.length > 0 || that.invoice.invoice_packages.length > 0)
|
708
695
|
{
|
709
696
|
table.append($('<tr/>').append($('<th/>').attr('colspan', '6').html(' ')));
|
710
697
|
}
|
711
698
|
|
712
|
-
if (that.
|
699
|
+
if (that.invoice.line_items.length > 0)
|
713
700
|
{
|
714
|
-
table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.
|
715
|
-
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', '
|
716
|
-
table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.
|
717
|
-
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', '
|
718
|
-
if (that.
|
701
|
+
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))));
|
702
|
+
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'))));
|
703
|
+
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))));
|
704
|
+
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'))));
|
705
|
+
if (that.invoice.discounts)
|
719
706
|
{
|
720
|
-
$.each(that.
|
707
|
+
$.each(that.invoice.discounts, function(i, d) {
|
721
708
|
table.append($('<tr/>')
|
722
709
|
.append($('<td/>').attr('colspan', '5').attr('align', 'right')
|
723
710
|
.append($('<a/>').attr('href', '#').html('Remove').click(function(e) { that.remove_discount(d.id); }))
|
@@ -727,14 +714,14 @@ OrderController.prototype = {
|
|
727
714
|
);
|
728
715
|
});
|
729
716
|
}
|
730
|
-
table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').append($('<div/>').attr('id', '
|
731
|
-
table.append($('<tr/>').append($('<td/>').attr('colspan', '5').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total').html(curr(that.
|
717
|
+
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'))));
|
718
|
+
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))));
|
732
719
|
}
|
733
720
|
else
|
734
721
|
{
|
735
722
|
table.append($('<tr/>').append($('<td/>').attr('colspan', '6')
|
736
723
|
.append($('<p/>')
|
737
|
-
.append('There are no items in this
|
724
|
+
.append('There are no items in this invoice. ')
|
738
725
|
.append($('<a/>').attr('href','#').html('Add one!').click(function(e) {
|
739
726
|
e.preventDefault();
|
740
727
|
that.add_variant();
|
@@ -748,26 +735,12 @@ OrderController.prototype = {
|
|
748
735
|
{
|
749
736
|
var that = this;
|
750
737
|
var p = $('<p/>');
|
751
|
-
p.append($('<input/>').attr('type', 'button').val('< Back').click(function() { window.location = '/admin/
|
752
|
-
if (that.
|
753
|
-
|
754
|
-
switch (that.order.financial_status)
|
755
|
-
{
|
756
|
-
case 'pending':
|
757
|
-
p.append($('<input/>').attr('type', 'button').val('Send for Authorization').click(function() { that.send_for_authorization(); })).append(' ');
|
758
|
-
break;
|
759
|
-
case 'authorized':
|
760
|
-
p.append($('<input/>').attr('type', 'button').val('Capture Funds').click(function() { that.capture_funds(); })).append(' ');
|
761
|
-
p.append($('<input/>').attr('type', 'button').val('Void' ).click(function() { that.void_order(); })).append(' ');
|
762
|
-
break;
|
763
|
-
case 'captured':
|
764
|
-
p.append($('<input/>').attr('type', 'button').val('Refund' ).click(function() { that.refund(); })).append(' ');
|
765
|
-
break;
|
766
|
-
}
|
767
|
-
}
|
738
|
+
p.append($('<input/>').attr('type', 'button').val('< Back').click(function() { window.location = '/admin/invoices'; })).append(' ');
|
739
|
+
if (that.invoice.total > 0 && that.invoice.financial_status == 'pending')
|
740
|
+
p.append($('<input/>').attr('type', 'button').val('Send for Authorization').click(function() { that.send_for_authorization(); })).append(' ');
|
768
741
|
//p.append($('<input/>').attr('type', 'button').val('Resend Confirmation' ).click(function() { that.resend_confirmation(); })).append(' ');
|
769
742
|
p.append($('<input/>').attr('type', 'button').val('Add Item' ).click(function() { that.add_variant(); })).append(' ');
|
770
|
-
p.append($('<input/>').attr('type', 'button').val('Print
|
743
|
+
p.append($('<input/>').attr('type', 'button').val('Print Invoice' ).click(function() { that.print_invoice(); })).append(' ');
|
771
744
|
$('#controls').empty().append(p);
|
772
745
|
},
|
773
746
|
|
@@ -778,11 +751,11 @@ OrderController.prototype = {
|
|
778
751
|
var that = this;
|
779
752
|
if (!variant_id)
|
780
753
|
{
|
781
|
-
caboose_modal_url('/admin/
|
754
|
+
caboose_modal_url('/admin/invoices/' + this.invoice.id + '/line-items/new');
|
782
755
|
return;
|
783
756
|
}
|
784
757
|
$.ajax({
|
785
|
-
url: '/admin/
|
758
|
+
url: '/admin/invoices/' + that.invoice.id + '/line-items',
|
786
759
|
type: 'post',
|
787
760
|
data: { variant_id: variant_id },
|
788
761
|
success: function(resp) {
|
@@ -792,11 +765,11 @@ OrderController.prototype = {
|
|
792
765
|
});
|
793
766
|
},
|
794
767
|
|
795
|
-
|
768
|
+
delete_invoice_package: function(invoice_package_id)
|
796
769
|
{
|
797
770
|
var that = this;
|
798
771
|
$.ajax({
|
799
|
-
url: '/admin/
|
772
|
+
url: '/admin/invoices/' + that.invoice.id + '/packages/' + invoice_package_id,
|
800
773
|
type: 'delete',
|
801
774
|
success: function(resp) {
|
802
775
|
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
@@ -809,7 +782,7 @@ OrderController.prototype = {
|
|
809
782
|
{
|
810
783
|
var that = this;
|
811
784
|
$.ajax({
|
812
|
-
url: '/admin/
|
785
|
+
url: '/admin/invoices/' + that.invoice.id + '/line-items/' + li_id,
|
813
786
|
type: 'delete',
|
814
787
|
success: function(resp) {
|
815
788
|
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
@@ -818,14 +791,14 @@ OrderController.prototype = {
|
|
818
791
|
});
|
819
792
|
},
|
820
793
|
|
821
|
-
|
794
|
+
void_invoice: function(confirm)
|
822
795
|
{
|
823
796
|
var that = this;
|
824
797
|
if (!confirm)
|
825
798
|
{
|
826
799
|
var p = $('<p/>').addClass('note confirm')
|
827
|
-
.append("Are you sure you want to void this
|
828
|
-
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.
|
800
|
+
.append("Are you sure you want to void this invoice? ")
|
801
|
+
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.void_invoice(true); }))
|
829
802
|
.append(' ')
|
830
803
|
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); }));
|
831
804
|
$('#message').empty().append(p);
|
@@ -833,7 +806,7 @@ OrderController.prototype = {
|
|
833
806
|
}
|
834
807
|
$('#message').html("<p class='loading'>Voiding...</p>");
|
835
808
|
$.ajax({
|
836
|
-
url: '/admin/
|
809
|
+
url: '/admin/invoices/' + that.invoice.id + '/void',
|
837
810
|
success: function(resp) {
|
838
811
|
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
839
812
|
if (resp.success) { $('#message').empty(); that.refresh(); }
|
@@ -842,26 +815,165 @@ OrderController.prototype = {
|
|
842
815
|
});
|
843
816
|
},
|
844
817
|
|
845
|
-
|
818
|
+
/*****************************************************************************
|
819
|
+
/* Transactions
|
820
|
+
*****************************************************************************/
|
821
|
+
|
822
|
+
refresh_transactions: function()
|
823
|
+
{
|
824
|
+
var that = this;
|
825
|
+
$('#transactions_message').html("<p class='loading'>Refreshing transactions...</p>");
|
826
|
+
$.ajax({
|
827
|
+
url: '/admin/invoices/' + that.invoice.id + '/refresh-transactions',
|
828
|
+
type: 'get',
|
829
|
+
success: function(resp) {
|
830
|
+
if (resp.error) $('#financial_status').html("Error: " + resp.error);
|
831
|
+
else
|
832
|
+
{
|
833
|
+
that.invoice.financial_status = resp.financial_status;
|
834
|
+
that.invoice.invoice_transactions = resp.invoice_transactions;
|
835
|
+
$('#transactions').empty().append(that.transactions_table());
|
836
|
+
}
|
837
|
+
}
|
838
|
+
});
|
839
|
+
},
|
840
|
+
|
841
|
+
transactions_table: function()
|
842
|
+
{
|
843
|
+
var that = this;
|
844
|
+
var div = $('<div/>')
|
845
|
+
.append($('<span/>').attr('id', 'financial_status').append(that.invoice.financial_status)).append(' ')
|
846
|
+
.append($('<a/>').attr('href', '#').html('refresh').click(function(e) { e.preventDefault(); that.refresh_transactions(); }))
|
847
|
+
.append($('<div/>').attr('id', 'transactions_message'));
|
848
|
+
if (that.invoice.invoice_transactions.length > 0)
|
849
|
+
{
|
850
|
+
var transactions_table = $('<table/>').addClass('data');
|
851
|
+
$.each(that.invoice.invoice_transactions, function(i, t) {
|
852
|
+
if (t.parent_id == null)
|
853
|
+
{
|
854
|
+
var link = $('<div/>').append($('<div/>').append(t.transaction_type));
|
855
|
+
if (!t.captured) link.append($('<a/>').attr('href', '#').html('Capture' ).data('transaction_id', t.id).click(function(e) { e.preventDefault(); that.capture_transaction($(this).data('transaction_id')); })).append(' ');
|
856
|
+
if (!t.refunded) link.append($('<a/>').attr('href', '#').html('Refund' ).data('transaction_id', t.id).click(function(e) { e.preventDefault(); that.refund_transaction($(this).data('transaction_id')); }));
|
857
|
+
|
858
|
+
transactions_table.append($('<tr/>')
|
859
|
+
.append($('<td/>').append($('<a/>').attr('href', '#').data('transaction_id', t.id).html(formatted_date(t.date_processed)).click(function(e) { e.preventDefault(); $('#trans_row_' + $(this).data('transaction_id')).slideToggle(); })))
|
860
|
+
.append($('<td/>').append(link))
|
861
|
+
.append($('<td/>').html(curr(t.amount) ))
|
862
|
+
//.append($('<td/>').html(t.transaction_id ))
|
863
|
+
.append($('<td/>').html(t.success ? 'Success' : 'Fail'))
|
864
|
+
);
|
865
|
+
transactions_table.append($('<tr/>').append($('<td/>').attr('colspan', '4').css('padding', '0').append($('<div/>').attr('id', 'trans_row_' + t.id).css('display', 'none').css('padding', '4px 8px').html(t.transaction_id))))
|
866
|
+
$.each(that.invoice.invoice_transactions, function(j, t2) {
|
867
|
+
if (t2.parent_id == t.id)
|
868
|
+
{
|
869
|
+
transactions_table.append($('<tr/>')
|
870
|
+
.append($('<td/>').append($('<a/>').attr('href', '#').data('transaction_id', t2.id).html(formatted_date(t2.date_processed)).click(function(e) { e.preventDefault(); $('#trans_row_' + $(this).data('transaction_id')).slideToggle(); })))
|
871
|
+
.append($('<td/>').html(t2.transaction_type ))
|
872
|
+
.append($('<td/>').html(curr(t2.amount) ))
|
873
|
+
//.append($('<td/>').html(t2.transaction_id ))
|
874
|
+
.append($('<td/>').html(t2.success ? 'Success' : 'Fail'))
|
875
|
+
);
|
876
|
+
transactions_table.append($('<tr/>').append($('<td/>').attr('colspan', '4').css('padding', '0').append($('<div/>').attr('id', 'trans_row_' + t2.id).css('display', 'none').css('padding', '4px 8px').html(t2.transaction_id))))
|
877
|
+
}
|
878
|
+
});
|
879
|
+
}
|
880
|
+
});
|
881
|
+
div.append(transactions_table);
|
882
|
+
}
|
883
|
+
return div;
|
884
|
+
},
|
885
|
+
|
886
|
+
//capture_funds: function(confirm)
|
887
|
+
//{
|
888
|
+
// var that = this;
|
889
|
+
// if (!confirm)
|
890
|
+
// {
|
891
|
+
// var p = $('<p/>').addClass('note confirm')
|
892
|
+
// .append("Are you sure you want to charge $" + parseFloat(that.invoice.total).toFixed(2) + " to the customer? ")
|
893
|
+
// .append($('<input/>').attr('type','button').val('Yes').click(function() { that.capture_funds(true); }))
|
894
|
+
// .append(' ')
|
895
|
+
// .append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); }));
|
896
|
+
// $('#message').empty().append(p);
|
897
|
+
// return;
|
898
|
+
// }
|
899
|
+
// $('#message').html("<p class='loading'>Capturing funds...</p>");
|
900
|
+
// $.ajax({
|
901
|
+
// url: '/admin/invoices/' + that.invoice.id + '/capture',
|
902
|
+
// success: function(resp) {
|
903
|
+
// if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
904
|
+
// if (resp.success) { $('#message').empty(); that.refresh(); }
|
905
|
+
// if (resp.refresh) { $('#message').empty(); that.refresh(); }
|
906
|
+
// }
|
907
|
+
// });
|
908
|
+
//},
|
909
|
+
|
910
|
+
capture_transaction: function(transaction_id, confirm)
|
846
911
|
{
|
847
912
|
var that = this;
|
913
|
+
var t = that.transaction_with_id(transaction_id);
|
848
914
|
if (!confirm)
|
849
915
|
{
|
850
916
|
var p = $('<p/>').addClass('note confirm')
|
851
|
-
.append("Are you sure you want to charge $" + parseFloat(
|
852
|
-
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.
|
917
|
+
.append("Are you sure you want to charge $" + parseFloat(t.amount).toFixed(2) + " to the customer?<br />")
|
918
|
+
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.capture_transaction(transaction_id, true); }))
|
853
919
|
.append(' ')
|
854
|
-
.append($('<input/>').attr('type','button').val('No').click(function() { $('#
|
855
|
-
$('#
|
920
|
+
.append($('<input/>').attr('type','button').val('No').click(function() { $('#transactions_message').empty(); }));
|
921
|
+
$('#transactions_message').empty().append(p);
|
856
922
|
return;
|
857
923
|
}
|
858
|
-
$('#
|
924
|
+
$('#transactions_message').html("<p class='loading'>Capturing funds...</p>");
|
859
925
|
$.ajax({
|
860
|
-
url: '/admin/
|
926
|
+
url: '/admin/invoices/' + that.invoice.id + '/transactions/' + transaction_id + '/capture',
|
861
927
|
success: function(resp) {
|
862
928
|
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
863
|
-
if (resp.success) { $('#message').empty(); that.
|
864
|
-
if (resp.refresh) { $('#message').empty(); that.
|
929
|
+
if (resp.success) { $('#message').empty(); that.refresh_transactions(); }
|
930
|
+
if (resp.refresh) { $('#message').empty(); that.refresh_transactions(); }
|
931
|
+
}
|
932
|
+
});
|
933
|
+
},
|
934
|
+
|
935
|
+
refund_transaction: function(transaction_id, amount, confirm)
|
936
|
+
{
|
937
|
+
var that = this;
|
938
|
+
var t = that.transaction_with_id(transaction_id);
|
939
|
+
var amount_available_to_refund = parseFloat(t.amount) - parseFloat(t.amount_refunded);
|
940
|
+
|
941
|
+
if (!amount)
|
942
|
+
{
|
943
|
+
var p = $('<p/>').addClass('note confirm')
|
944
|
+
.append("Refund amount: $")
|
945
|
+
.append($('<input/>').attr('type','text').attr('id', 'refund_amount').val(amount_available_to_refund.toFixed(2)).css('width', '60px').css('text-align', 'right')).append($('<br/>'))
|
946
|
+
.append($('<input/>').attr('type','button').val('Continue').click(function() { that.refund_transaction(transaction_id, parseFloat($('#refund_amount').val())); })).append(' ')
|
947
|
+
.append($('<input/>').attr('type','button').val('Cancel').click(function() { $('#transactions_message').empty(); }));
|
948
|
+
$('#transactions_message').empty().append(p);
|
949
|
+
return;
|
950
|
+
}
|
951
|
+
if (amount > amount_available_to_refund)
|
952
|
+
{
|
953
|
+
var p = $('<p/>').addClass('note error')
|
954
|
+
.append("You can only refund a maximum of $" + amount_available_to_refund.toFixed(2) + ". ").append($('<br/>'))
|
955
|
+
.append($('<input/>').attr('type','button').val('Back' ).click(function() { that.refund_transaction(transaction_id); })).append(' ')
|
956
|
+
.append($('<input/>').attr('type','button').val('Cancel' ).click(function() { $('#transactions_message').empty(); }));
|
957
|
+
$('#transactions_message').empty().append(p);
|
958
|
+
return;
|
959
|
+
}
|
960
|
+
if (!confirm)
|
961
|
+
{
|
962
|
+
var x = parseFloat(t.amount) - parseFloat(t.amount_refunded);
|
963
|
+
var p = $('<p/>').addClass('note confirm')
|
964
|
+
.append("Are you sure you want to refund $" + amount.toFixed(2) + " to the customer? ").append($('<br/>'))
|
965
|
+
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.refund_transaction(transaction_id, amount, true); })).append(' ')
|
966
|
+
.append($('<input/>').attr('type','button').val('No' ).click(function() { $('#transactions_message').empty(); }));
|
967
|
+
$('#transactions_message').empty().append(p);
|
968
|
+
return;
|
969
|
+
}
|
970
|
+
$('#transactions_message').html("<p class='loading'>Refunding...</p>");
|
971
|
+
$.ajax({
|
972
|
+
url: '/admin/invoices/' + that.invoice.id + '/transactions/' + transaction_id + '/refund',
|
973
|
+
data: { amount: amount },
|
974
|
+
success: function(resp) {
|
975
|
+
if (resp.error) $('#transactions_message').html("<p class='note error'>" + resp.error + "</p>");
|
976
|
+
if (resp.success) { $('#transactions_message').empty(); that.refresh_transactions(); }
|
865
977
|
}
|
866
978
|
});
|
867
979
|
},
|
@@ -872,7 +984,7 @@ OrderController.prototype = {
|
|
872
984
|
if (!confirm)
|
873
985
|
{
|
874
986
|
var p = $('<p/>').addClass('note confirm')
|
875
|
-
.append("Are you sure you want to send this
|
987
|
+
.append("Are you sure you want to send this invoice to the customer for authorization? ")
|
876
988
|
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.send_for_authorization(true); }))
|
877
989
|
.append(' ')
|
878
990
|
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); }));
|
@@ -881,7 +993,7 @@ OrderController.prototype = {
|
|
881
993
|
}
|
882
994
|
$('#message').html("<p class='loading'>Sending for authorization...</p>");
|
883
995
|
$.ajax({
|
884
|
-
url: '/admin/
|
996
|
+
url: '/admin/invoices/' + that.invoice.id + '/send-for-authorization',
|
885
997
|
success: function(resp) {
|
886
998
|
if (resp.error) { that.flash_error(resp.error); }
|
887
999
|
if (resp.success) { that.refresh(function() { that.flash_success("An email has been sent successfully to the customer."); }); }
|
@@ -893,8 +1005,8 @@ OrderController.prototype = {
|
|
893
1005
|
{
|
894
1006
|
var that = this;
|
895
1007
|
$.ajax({
|
896
|
-
url: '/admin/
|
897
|
-
success: function(resp) { that.
|
1008
|
+
url: '/admin/invoices/' + that.invoice_id + '/calculate-tax',
|
1009
|
+
success: function(resp) { that.refresh_invoice(function() { $('#invoice_' + that.invoice.id + '_tax').val(that.invoice.tax); }); }
|
898
1010
|
});
|
899
1011
|
},
|
900
1012
|
|
@@ -902,27 +1014,27 @@ OrderController.prototype = {
|
|
902
1014
|
{
|
903
1015
|
var that = this;
|
904
1016
|
$.ajax({
|
905
|
-
url: '/admin/
|
906
|
-
success: function(resp) { that.
|
1017
|
+
url: '/admin/invoices/' + that.invoice_id + '/calculate-handling',
|
1018
|
+
success: function(resp) { that.refresh_invoice(function() { $('#invoice_' + that.invoice.id + '_handling').val(that.invoice.handling); }); }
|
907
1019
|
});
|
908
1020
|
},
|
909
1021
|
|
910
|
-
calculate_shipping: function(
|
1022
|
+
calculate_shipping: function(invoice_package_id)
|
911
1023
|
{
|
912
1024
|
var that = this;
|
913
|
-
$('#
|
1025
|
+
$('#invoice_package_' + invoice_package_id + '_message').html("<p class='loading'>Calculating...</p>");
|
914
1026
|
var shipping_method_id = $('');
|
915
1027
|
$.ajax({
|
916
|
-
url: '/admin/
|
1028
|
+
url: '/admin/invoices/' + that.invoice_id + '/packages/' + invoice_package_id + '/calculate-shipping',
|
917
1029
|
success: function(resp) {
|
918
1030
|
if (resp.error)
|
919
|
-
$('#
|
1031
|
+
$('#invoice_package_' + invoice_package_id + '_message').html("<p class='note error'>" + resp.error + "</p>");
|
920
1032
|
else
|
921
1033
|
{
|
922
|
-
that.
|
923
|
-
$('#
|
1034
|
+
that.refresh_invoice(function() {
|
1035
|
+
$('#invoicepackage_' + invoice_package_id + '_total').val(resp.rate);
|
924
1036
|
});
|
925
|
-
$('#
|
1037
|
+
$('#invoice_package_' + invoice_package_id + '_message').empty();
|
926
1038
|
}
|
927
1039
|
}
|
928
1040
|
});
|
@@ -932,7 +1044,7 @@ OrderController.prototype = {
|
|
932
1044
|
{
|
933
1045
|
var that = this;
|
934
1046
|
var needs_shipping = false;
|
935
|
-
$.each(that.
|
1047
|
+
$.each(that.invoice.line_items, function(i, li) {
|
936
1048
|
if (li.variant.downloadable == false)
|
937
1049
|
needs_shipping = true;
|
938
1050
|
});
|
@@ -946,14 +1058,14 @@ OrderController.prototype = {
|
|
946
1058
|
if (!length) length = 5000;
|
947
1059
|
$('#message').empty().append(str);
|
948
1060
|
setTimeout(function() { $('#message').slideUp(function() { $('#message').empty().show(); }); }, length);
|
949
|
-
}
|
1061
|
+
},
|
950
1062
|
|
951
|
-
//resend_confirmation: function(
|
1063
|
+
//resend_confirmation: function(invoice_id)
|
952
1064
|
//{
|
953
1065
|
// modal.autosize("<p class='loading'>Resending confirmation..</p>");
|
954
1066
|
// $.ajax({
|
955
1067
|
// type: 'post',
|
956
|
-
// url: '/admin/
|
1068
|
+
// url: '/admin/invoices/' + invoice_id + '/resend-confirmation',
|
957
1069
|
// success: function(resp) {
|
958
1070
|
// if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
959
1071
|
// if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
@@ -962,13 +1074,13 @@ OrderController.prototype = {
|
|
962
1074
|
//},
|
963
1075
|
//
|
964
1076
|
//
|
965
|
-
//
|
1077
|
+
//refund_invoice: function(invoice_id, confirm)
|
966
1078
|
//{
|
967
1079
|
// if (!confirm)
|
968
1080
|
// {
|
969
1081
|
// var p = $('<p/>').addClass('note confirm')
|
970
|
-
// .append("Are you sure you want to refund this
|
971
|
-
// .append($('<input/>').attr('type','button').val('Yes').click(function() {
|
1082
|
+
// .append("Are you sure you want to refund this invoice? ")
|
1083
|
+
// .append($('<input/>').attr('type','button').val('Yes').click(function() { refund_invoice(invoice_id, true); }))
|
972
1084
|
// .append(' ')
|
973
1085
|
// .append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
974
1086
|
// modal.autosize(p);
|
@@ -976,7 +1088,7 @@ OrderController.prototype = {
|
|
976
1088
|
// }
|
977
1089
|
// modal.autosize("<p class='loading'>Refunding...</p>");
|
978
1090
|
// $.ajax({
|
979
|
-
// url: '/admin/
|
1091
|
+
// url: '/admin/invoices/' + invoice_id + '/refund',
|
980
1092
|
// success: function(resp) {
|
981
1093
|
// if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
982
1094
|
// if (resp.success) modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
@@ -985,4 +1097,35 @@ OrderController.prototype = {
|
|
985
1097
|
// });
|
986
1098
|
//},
|
987
1099
|
|
1100
|
+
transaction_with_id: function(transaction_id)
|
1101
|
+
{
|
1102
|
+
var that = this;
|
1103
|
+
var t = false;
|
1104
|
+
$.each(that.invoice.invoice_transactions, function(i, t2) {
|
1105
|
+
if (t2.id == transaction_id)
|
1106
|
+
{
|
1107
|
+
t = t2;
|
1108
|
+
return false;
|
1109
|
+
}
|
1110
|
+
});
|
1111
|
+
return t;
|
1112
|
+
}
|
988
1113
|
};
|
1114
|
+
|
1115
|
+
function formatted_date(str)
|
1116
|
+
{
|
1117
|
+
the_date = new Date(str);
|
1118
|
+
var h = the_date.getHours();
|
1119
|
+
var i = the_date.getMinutes(); if (i < 10) i = '0' + i;
|
1120
|
+
|
1121
|
+
var ampm = 'am';
|
1122
|
+
if (h >= 12) ampm = 'pm';
|
1123
|
+
if (h > 12) h = h - 12;
|
1124
|
+
if (h < 10) h = '0' + h;
|
1125
|
+
|
1126
|
+
var m = the_date.getMonth()+1; if (m < 10) m = '0' + m;
|
1127
|
+
var d = the_date.getDate(); if (d < 10) d = '0' + d;
|
1128
|
+
var y = the_date.getFullYear();
|
1129
|
+
|
1130
|
+
return '' + m + '/' + d + '/' + y + '<br/>' + h + ':' + i + ' ' + ampm;
|
1131
|
+
}
|