jQuery(document).ready(function($) { if($("#DS_AddItem_ItemID").length) $("#DS_AddItem_ItemID").change(ds_addItem_updateQty); if($("#DS_AddItem_ItemID").length) $("#DS_AddItem_ItemID").ready(ds_addItem_updateQty); if($("#DS_ReceiveItem_ItemID").length) $("#DS_ReceiveItem_ItemID").change(ds_receiveItem_updateQty); if($("#DS_ReceiveItem_ItemID").length) $("#DS_ReceiveItem_ItemID").ready(ds_receiveItem_updateQty); if($('#DS_Error').length){ //window.alert('exists'); } else { $('body').append('
'); $("#DS_Error").hide(); } }); function ds_addItem_updateQty(qtySelected){ var selected = $("#DS_AddItem_ItemID option:selected"); var val = selected.val(); if(val != ""){ var AvailPer = ds_addItem_qtyLookup(val); var options = ''; var count = 0; var arrAvailPer = AvailPer.split(','); var Avail = arrAvailPer[0]; var Per = arrAvailPer[1]; //alert(Avail); for(var i = 0; i*Per <= Avail; i++){ var qty = i * Per; var selected = ''; if(qty == qtySelected){ selected = " SELECTED"; } options += ""; count++; if(count > 500){ break; } } $("#DS_AddItem_AllocLink").attr("href",'ds_item_allocations.php?ItemID=' + val); $("#DS_AddItem_ItemQty").html(options); var ItemImage = ds_itemImage_lookup(val); if(ItemImage==''){ $("#DS_AddItem_ImageDiv").hide(); }else { $("#DS_AddItem_ImageDiv").show(); var arrImage = ItemImage.split('.'); var imageLink = `https://cdn.bdtshop.com/cdn-cgi/imagedelivery/5GgHi7cPI_Yf31ZjcnV-4g/ds-image-${arrImage[0]}/600?${new Date().valueOf()}`; //var imageLink = "/sites/" + JS_SITE_ID + "/ds_items/" + "" + arrImage[0] + "_600." + arrImage[1]; //alert(imageLink); $("#DS_AddItem_ImageLink").attr("href",imageLink); } $("#DS_AddItem_AllocDiv").show(); } else { var options = ""; $("#DS_AddItem_ItemQty").html(options); $("#DS_AddItem_AllocDiv").hide(); $("#DS_AddItem_ImageDiv").hide(); } } function ds_itemImage_lookup(ItemID){ if(typeof(ds_arrItemImage) == "undefined"){ return "0,0"; } var ItemImage = ds_arrItemImage[ItemID]; if(ItemImage != ''){ return ItemImage; } return ""; } function ds_addItem_qtyLookup(ItemID){ if(typeof(ds_arrItemAvailable) == "undefined"){ return "0,0"; } var qty = ds_arrItemAvailable[ItemID]; if(qty != ''){ return qty; } return "0,0"; } function ds_receiveItem_updateQty(qtySelected){ var selected = $("#DS_ReceiveItem_ItemID option:selected"); var val = selected.val(); if(val != ""){ var toReceive = ds_receiveItem_qtyLookup(val); var options = ''; var count = 0; for(var i = 0; i <= toReceive; i++){ var qty = i; var selected = ''; if(qty == qtySelected){ selected = " SELECTED"; } options += ""; count++; //if(count > 500){ // break; //} } $("#DS_ReceiveItem_ItemQty").html(options); $("#btnReceiveAll").attr("value","Receive " + toReceive); } else { var options = ""; $("#DS_ReceiveItem_ItemQty").html(options); $("#btnReceiveAll").attr("value","Receive"); } } function ds_receiveItem_qtyLookup(ItemID){ if(typeof(ds_arrUnreceivedItems) == "undefined"){ return "0"; } var qty = ds_arrUnreceivedItems[ItemID]; if(qty != ''){ return qty; } return "0"; } function ds_undoReturn(HistoryID,ItemID,Qty){ var x = window.confirm("Are you sure you wish to undo the return of this item?"); if(x){ $("#DS_UndoReturn_ItemID").attr("value",ItemID); $("#DS_UndoReturn_HistoryID").attr("value",HistoryID); $("#DS_UndoReturn_HistoryQty").attr("value",Qty); //document.getElementById('DS_UndoReturn_Form').submit(); $('#DS_UndoReturn_Form').submit(); return true; } return false; } function ds_makeAvailable(HistoryID,ItemID,Qty){ var x = window.confirm("Are you sure you wish to lock the return of this item? It will make it so that the return cannot be undone and will make this item available to other orders."); if(x){ $("#DS_MakeAvailable_ItemID").attr("value",ItemID); $("#DS_MakeAvailable_HistoryID").attr("value",HistoryID); $("#DS_MakeAvailable_HistoryQty").attr("value",Qty); $('#DS_MakeAvailable_Form').submit(); return true; } return false; } function ds_finalizeOrder(){ var x = window.confirm("Are you sure you wish to finalize this order? Any items not received will be marked as consumed. This action is not undoable."); if(x){ return true; } return false; } function ds_viewOrders(OrderStatus){ document.location.href='ds_orders.php?OrderStatus=' + OrderStatus; return; } function ds_viewOrder(OrderID){ document.location.href='ds_order.php?OrderID=' + OrderID; return; } //function ds_editOrderSection(Section,OrderID){ // if(Section=='shippingAddress'){ // document.location.href='ds_order_shippingaddress.php'; // return; // } // if(Section=='shippingDetails'){ // document.location.href='ds_order_shippingdetails.php'; // return; // } // if(Section=='specialInstructions'){ // document.location.href='ds_order_special.php'; // return; // } // if(Section=='items'){ // document.location.href='ds_order_items.php'; // return; // } // alert(Section); // return; //} //function ds_editShipAddr(addressID){ // var id = trim('' + addressID); // if(id != ''){ // document.location.href="addressbook_edit.php?AID=" + id + "&AT=DS_SHIP"; // } //} //function ds_deleteShipAddr(addressID){ // var id = trim('' + addressID); // if(id != '' && window.confirm("Are you sure?")){ // document.location.href="ds_order_shippingaddress.php?a=deleteExisting&AID=" + id; // } //} function ds_showItemAllocations(itemID){ if(itemID == ""){ return true; } return true; jQuery.facebox({ ajax: 'ds_item_allocations.php?ItemID=' + itemID}); //var url = 'ds_item_allocations.php?ItemID=' + itemID; //alert(url); //$.fancybox( // { // 'autoDimensions' : true, // 'transitionIn' : 'none', // 'transitionOut' : 'none', // 'href' : url, // 'type' : 'ajax' // } //); return true; } function ds_addItem_editQty(ItemID){ //window.alert(ItemID); $('.ds_additem_currentEdit').hide(); // HIDE ANY OTHER SHOWING EDIT BOXES $('.ds_additem_normalEdit').show(); // SHOW QTY SELECT FOR THIS ITEM $('#DS_AddItem_ItemList_Qty_'+ItemID).hide(); $('#DS_AddItem_ItemList_QtyEdit_'+ItemID).show(); $('#DS_AddItem_ItemList_Actions_'+ItemID).hide(); $('#DS_AddItem_ItemList_ActionsEdit_'+ItemID).show(); } function ds_addItem_editQtyCommit(ItemID){ //window.alert(ItemID); var ItemQty = $('#DS_AddItem_ItemList_QtyField_' + ItemID).val(); $('#DS_EditItem_ItemID').attr({value: ItemID}); $('#DS_EditItem_ItemQty').attr({value: ItemQty}); $('#DS_EditItem_Form').submit(); return true; $('#DS_AddItem_ItemList_QtyEdit_'+ItemID).hide(); $('#DS_AddItem_ItemList_Qty_'+ItemID).show(); $('#DS_AddItem_ItemList_ActionsEdit_'+ItemID).hide(); $('#DS_AddItem_ItemList_Actions_'+ItemID).show(); } function ds_addItem_editQtyCancel(ItemID){ //window.alert(ItemID); //var x = window.confirm("Discard your changes to this item's quantity?"); //if(x == false) // return; $('#DS_AddItem_ItemList_QtyEdit_'+ItemID).hide(); $('#DS_AddItem_ItemList_Qty_'+ItemID).show(); $('#DS_AddItem_ItemList_ActionsEdit_'+ItemID).hide(); $('#DS_AddItem_ItemList_Actions_'+ItemID).show(); } function ds_addItem_remove(ItemID){ var x = window.confirm("Are you sure you wish to remove this item from the order?"); if(x == false){ return false; } $('#DS_EditItem_ItemID').attr({value: ItemID}); $('#DS_EditItem_ItemQty').attr({value: '0'}); $('#DS_EditItem_Form').submit(); return true; } function ds_confirmOrderSubmitOld(){ var x = window.confirm("Once you submit an order, you cannot make changes to it without calling Customer Service. Proceed?"); if(x){ //$('#frmDSOrderSubmit').submit(function(){return true;}); return $('#frmDSOrderSubmit').submit(); //document.getElementById('frmDSOrderSubmit').submit(); //return true; } else { return false; } } function ds_viewOrderWithConfirmation(OrderID){ var x = window.confirm('Do you wish to view Order #' + OrderID + '? This will take you off the current page.'); if(x){ document.location.href='ds_order.php?OrderID=' + OrderID; return true; } return false; } function ds_consumeComplete(){ var x = window.confirm("This will consume all items on this order and mark it as complete. If you need to receive items, please use the receive button above. This action cannot be undone. Proceed?"); if(x){ return $('#frmDSOrderConsumeComplete').submit(); } else { return false; } } //function ds_displayShowPacket(OrderID){ // document.location.href='ds_pdf_showpacket.php?OrderID=' + OrderID; // return true; //} //function ds_displayShowPacketAndPack(OrderID){ // document.location.href='ds_pdf_showpacket.php?Pack=1&OrderID=' + OrderID; // return true; //} //function ds_displayPostReport(OrderID){ // document.location.href='ds_pdf_post.php?OrderID=' + OrderID; // return true; //} //function ds_receiveOrder(OrderID){ // document.location.href='ds_order_receive.php?OrderID=' + OrderID; // return true; //} function ds_saveOrder(){ document.location.href='ds_orders.php'; return; } function ds_incompleteOrder(){ return ds_error('Oops! This order is incomplete. You must provide a shipping address, shipping details, and request items for an order to be complete. Please complete the order and try again.'); } function ds_noEditRights(){ return ds_error('Oops! You do not have sufficient rights to edit this order.'); } function ds_error(strText){ if(strText != ''){ alert(strText); return true; $('#DS_Error').html(strText); $("#DS_Error").show(); jQuery.facebox($('#DS_Error')); return true; } } function ds_removeTracking(id){ var x = window.confirm("Are you sure you wish to remove this tracking number? This action cannot be undone."); if(x){ //alert(id); $('#DS_RemoveTracking_TrackingID').attr({value: id}); return $('#frmRemoveTracking').submit(); } else { return false; } }