Skip to content

Commit

Permalink
Added support for ad valorem insurance in back-office
Browse files Browse the repository at this point in the history
  • Loading branch information
tbelliard committed May 18, 2017
1 parent aead384 commit 66f5a9d
Show file tree
Hide file tree
Showing 12 changed files with 579 additions and 205 deletions.
53 changes: 30 additions & 23 deletions assets/js/admin.js
Expand Up @@ -28,13 +28,13 @@ jQuery( function ( $ ) {
.on( 'click', 'a.delete-shipment', this.delete_shipment );


$( '#myflyingbox-bulk-shipments' )
.on( 'click', 'div.mfb-available-offers button.book-offer', this.book_offer )
.on( 'click', 'div.mfb-booked-offer button.download-labels', this.download_labels )
.on( 'change', 'div.mfb-available-offers select.offer-selector', this.update_selected_offer );
},
$( '#myflyingbox-bulk-shipments' )
.on( 'click', 'div.mfb-available-offers button.book-offer', this.book_offer )
.on( 'click', 'div.mfb-booked-offer button.download-labels', this.download_labels )
.on( 'change', 'div.mfb-available-offers select.offer-selector', this.update_selected_offer );
},

add_shipment: function() {
add_shipment: function() {
var data = {
action: 'mfb_create_shipment',
order_id: mfb_js_resources.post_id
Expand All @@ -52,25 +52,32 @@ jQuery( function ( $ ) {
return false;
},

book_offer: function() {
book_offer: function() {

var offer_id = $( this ).closest('div.mfb-available-offers').find('select.offer-selector option:selected').data('offer_id');
var date_selector = $( this ).closest('div.mfb-available-offers').find('select.pickup-date-selector');
var relay_selector = $( this ).closest('div.mfb-available-offers').find('select.delivery-location-selector');
var insurance_checkbox = $( this ).closest('div.mfb-available-offers').find('input#mfb_ad_valorem_insurance');
var pickup_date = '';
var relay_code = '';
var insurance = '0';

if ( date_selector ) {
pickup_date = date_selector.val();
}
if ( relay_selector ) {
relay_code = relay_selector.val();
}
if ( insurance_checkbox.is(':checked') ) {
insurance = '1';
}

var data = {
action: 'mfb_book_offer',
offer_id: offer_id,
pickup_date: pickup_date,
relay_code: relay_code,
insurance: insurance,
shipment_id: $( this ).closest('tr').data('shipment_id')
};

Expand All @@ -90,7 +97,7 @@ jQuery( function ( $ ) {
return false;
},

update_selected_offer: function() {
update_selected_offer: function() {
var offer_id = $( this ).find('option:selected').data('offer_id');
var data = {
action: 'mfb_update_selected_offer',
Expand All @@ -110,7 +117,7 @@ jQuery( function ( $ ) {
return false;
},

delete_shipment: function() {
delete_shipment: function() {
var data = {
action: 'mfb_delete_shipment',
shipment_id: $( this ).closest('tr').data('shipment_id')
Expand All @@ -127,21 +134,21 @@ jQuery( function ( $ ) {
return false;
},

load_recipient_form: function( event ) {
load_recipient_form: function( event ) {
event.preventDefault();
// Initializing form dialogs
$( this ).closest('div.display_recipient_address').hide();
$( this ).closest('td').find('div.recipient_form_container').show();
},

load_shipper_form: function( event ) {
load_shipper_form: function( event ) {
event.preventDefault();
// Initializing form dialogs
$( this ).closest('div.display_shipper_address').hide();
$( this ).closest('td').find('div.shipper_form_container').show();
},

load_parcel_form: function( event ) {
load_parcel_form: function( event ) {
event.preventDefault();
// Initializing form dialogs
$( this ).closest('div.parcel-data').hide();
Expand All @@ -167,8 +174,8 @@ jQuery( function ( $ ) {
$( this ).closest('div.parcel').find('div.parcel-data').show();
},

submit_recipient_form: function( event ) {
event.preventDefault();
submit_recipient_form: function( event ) {
event.preventDefault();
var action = 'mfb_update_recipient';
var shipment_id = $( this ).closest('tr').data('shipment_id');
$.ajax({
Expand All @@ -181,8 +188,8 @@ jQuery( function ( $ ) {
});
return false;
},
submit_shipper_form: function( event ) {
event.preventDefault();
submit_shipper_form: function( event ) {
event.preventDefault();
var action = 'mfb_update_shipper';
var shipment_id = $( this ).closest('tr').data('shipment_id');
$.ajax({
Expand All @@ -195,8 +202,8 @@ jQuery( function ( $ ) {
});
return false;
},
submit_parcel_form: function( event ) {
event.preventDefault();
submit_parcel_form: function( event ) {
event.preventDefault();
var action = 'mfb_update_parcel';
var shipment_id = $( this ).closest('tr').data('shipment_id');
var parcel_index = $( this ).closest('div.parcel').data('parcel_index');
Expand All @@ -211,8 +218,8 @@ jQuery( function ( $ ) {
return false;
},

delete_parcel: function( event ) {
event.preventDefault();
delete_parcel: function( event ) {
event.preventDefault();
var action = 'mfb_delete_parcel';
var shipment_id = $( this ).closest('tr').data('shipment_id');
var parcel_index = $( this ).closest('div.parcel').data('parcel_index');
Expand All @@ -227,14 +234,14 @@ jQuery( function ( $ ) {
return false;
},

download_labels: function() {
download_labels: function() {
var shipment_id = $( this ).closest('tr').data('shipment_id');
window.open( mfb_js_resources.labels_url+'&shipment_id='+shipment_id );
return false;
},

};
};

mfb_meta_boxes_order.init();
mfb_meta_boxes_order.init();

});
2 changes: 1 addition & 1 deletion assets/js/admin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66f5a9d

Please sign in to comment.