app/assets/javascripts/caboose/admin_edit_order.js in caboose-cms-0.5.145 vs app/assets/javascripts/caboose/admin_edit_order.js in caboose-cms-0.5.146
- old
+ new
@@ -248,11 +248,12 @@
}
var table = $('<table/>').addClass('data');
table.append($('<tr/>')
.append($('<th/>').html('Customer'))
- .append($('<th/>').html('Shipping Address'))
+ .append($('<th/>').html('Shipping Address'))
+ .append($('<th/>').html('Billing Address'))
.append($('<th/>').html('Order Status'))
.append($('<th/>').html('Payment Status'))
);
table.append($('<tr/>')
.append($('<td/>').attr('valign', 'top')
@@ -273,10 +274,20 @@
if (a.html() == 'Edit') { that.edit_shipping_address(); a.html('Finished'); }
else { that.noneditable_shipping_address(); a.html('Edit'); }
});
}))
)
+ .append($('<td/>').attr('valign', 'top')
+ .append($('<div/>').attr('id', 'billing_address').append(that.noneditable_billing_address(true)))
+ .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
+ var a = $(this);
+ that.refresh_order(function() {
+ if (a.html() == 'Edit') { that.edit_billing_address(); a.html('Finished'); }
+ else { that.noneditable_billing_address(); a.html('Edit'); }
+ });
+ }))
+ )
.append($('<td/>').attr('valign', 'top').append($('<div/>').attr('id', 'order_' + that.order.id + '_status')))
.append($('<td/>').attr('valign', 'top').attr('align', 'center').append(fstatus))
);
return table;
},
@@ -368,10 +379,66 @@
{ name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
]
});
},
+ noneditable_billing_address: function(return_element)
+ {
+ var that = this;
+ var sa = that.order.billing_address;
+ if (!sa) sa = {};
+ var str = '';
+ str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
+ str += (sa.last_name ? sa.last_name : '[Empty last name]');
+ str += '<br />' + (sa.address1 ? sa.address1 : '[Empty address]');
+ if (sa.address2) str += "<br />" + sa.address2;
+ str += '<br/>' + (sa.city ? sa.city : '[Empty city]') + ", " + (sa.state ? sa.state : '[Empty state]') + " " + (sa.zip ? sa.zip : '[Empty zip]');
+ if (return_element)
+ return str;
+ $('#billing_address').empty().append(str);
+ },
+
+ edit_billing_address: function()
+ {
+ var that = this;
+ var sa = that.order.billing_address;
+ if (!sa) sa = { id: 1 };
+ var table = $('<table/>').addClass('billing_address')
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_first_name')))
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_last_name')))
+ ))))
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address1')))
+ ))))
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_address2')))
+ ))))
+ .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_city')))
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_state')))
+ .append($('<td/>').append($('<div/>').attr('id', 'billingaddress_' + sa.id + '_zip')))
+ ))));
+ $('#billing_address').empty().append(table);
+
+ new ModelBinder({
+ name: 'BillingAddress',
+ id: sa.id,
+ update_url: '/admin/orders/' + that.order.id + '/billing-address',
+ authenticity_token: that.authenticity_token,
+ attributes: [
+ { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
+ { name: 'last_name' , nice_name: 'Last Name' , type: 'text' , value: sa.last_name , width: 150, fixed_placeholder: false },
+ { name: 'address1' , nice_name: 'Address 1' , type: 'text' , value: sa.address1 , width: 320, fixed_placeholder: false },
+ { name: 'address2' , nice_name: 'Address 2' , type: 'text' , value: sa.address2 , width: 320, fixed_placeholder: false },
+ { name: 'city' , nice_name: 'City' , type: 'text' , value: sa.city , width: 180, fixed_placeholder: false },
+ { name: 'state' , nice_name: 'State' , type: 'text' , value: sa.state , width: 40, fixed_placeholder: false },
+ { name: 'zip' , nice_name: 'Zip' , type: 'text' , value: sa.zip , width: 60, fixed_placeholder: false }
+ ]
+ });
+ },
+
// Show all the packages and the line items in each package
order_packages_table: function(table)
{
var that = this;
$.each(that.order.order_packages, function(i, op) {
@@ -635,12 +702,12 @@
$('#message').html("<p class='loading'>Voiding...</p>");
$.ajax({
url: '/admin/orders/' + that.order.id + '/void',
success: function(resp) {
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
- if (resp.success) $('#message').html("<p class='note success'>" + resp.success + "</p>");
- if (resp.refresh) window.location.reload(true);
+ if (resp.success) that.refresh();
+ if (resp.refresh) that.refresh();
}
});
},
capture_funds: function(confirm)
@@ -659,11 +726,11 @@
$('#message').html("<p class='loading'>Capturing funds...</p>");
$.ajax({
url: '/admin/orders/' + that.order.id + '/capture',
success: function(resp) {
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
- if (resp.success) $('#message').html("<p class='note success'>" + resp.success + "</p>");
- if (resp.refresh) window.location.reload(true);
+ if (resp.success) that.refresh();
+ if (resp.refresh) that.refresh();
}
});
}
//resend_confirmation: function(order_id)
\ No newline at end of file