Rev 23343 | Rev 23500 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
var saleHistory=saleHistory || {};saleHistory.searchText="";saleHistory.searchType="";saleHistory.startTime="";saleHistory.endTime="";$(function() {$(".sale-history").live('click', function() {console.log("Sale History Button Clicked...")saleHistory("main-content","","","0","0");});$('#searchType').live('change', function() {var searchType = $(this).find('option:selected').text();console.log("selected searchType = " + searchType);$("#sale-history-search-text").attr('placeholder', 'Search By '+searchType);$("#sale-history-search-text").val('');});$("#sale-history-search-button").live('click', function() {console.log("sale-history-search-button clicked")var searchType = $("#searchType option:selected").val();console.log("searchType = " + searchType);$("#searchType").removeClass("border-highlight");if(searchType == ""){alert("Please choose Search Type");$("#searchType").addClass("border-highlight");}else{var startDateTime = $('input[name="startDateTime"]').val();console.log("startDateTime : "+startDateTime);var endDateTime = $('input[name="endDateTime"]').val();console.log("endDateTime : "+endDateTime);saleHistory.searchText = $("#sale-history-search-text").val();saleHistory.searchType = searchType;saleHistory.startTime = startDateTime;saleHistory.endTime = endDateTime;if (typeof (saleHistory.searchText) == "undefined" || !saleHistory.searchText){saleHistory.searchText = "";}saleHistorySearchInfo(saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);$("#sale-history-search-text").val(saleHistory.searchText);$("#searchType").val(searchType);$('input[name="startDateTime"]').val(saleHistory.startTime);$('input[name="endDateTime"]').val(saleHistory.endTime);}});$("#sale-history-paginated .next").live('click', function() {var start = $( "#sale-history-paginated .start" ).text();var end = $( "#sale-history-paginated .end" ).text();getSaleHistoryNextItems(start, end, saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);$("#sale-history-paginated .next").blur();});$("#sale-history-paginated .previous").live('click', function() {var start = $( "#sale-history-paginated .start" ).text();var end = $( "#sale-history-paginated .end" ).text();var size = $("#sale-history-paginated .size").text();if(parseInt(end) == parseInt(size)){var mod = parseInt(end) % 10;end = parseInt(end) + (10 - mod);}var pre = end - 20;getSaleHistoryPreviousItems(start, end, pre, saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);$("#sale-history-paginated .previous").blur();});//grn-details$(".sale-details").live('click',function(){var orderId = $(this).attr('data');console.log("orderId = "+orderId);loadSaleDetails(orderId,"sale-details-container");});});function getSaleHistoryNextItems(start, end, searchType, searchValue, startTime, endTime){console.log(start);console.log(end);console.log(+end + +10);console.log(+start + +10);doAjaxRequestHandler(context+"/getPaginatedSaleHistory/?searchType="+searchType+"&searchValue="+searchValue+"&startTime="+startTime+"&endTime="+endTime+"&offset="+end, "GET", function(response){var size = $("#sale-history-paginated .size").text();if((parseInt(end) + 10) > parseInt(size)){console.log("(end + 10) > size == true");$( "#sale-history-paginated .end" ).text(size);}else{console.log("(end + 10) > size == false");$( "#sale-history-paginated .end" ).text(+end + +10);}$( "#sale-history-paginated .start" ).text(+start + +10);var last = $( "#sale-history-paginated .end" ).text();var temp = $( "#sale-history-paginated .size" ).text();if (parseInt(last) >= parseInt(temp)){$("#sale-history-paginated .next").prop('disabled', true);//$( "#good-inventory-paginated .end" ).text(temp);}$('#sale-history-table').html(response);$("#sale-history-paginated .previous").prop('disabled', false);});}function getSaleHistoryPreviousItems(start, end, pre, searchType, searchValue, startTime, endTime){doAjaxRequestHandler(context+"/getPaginatedSaleHistory/?searchType="+searchType+"&searchValue="+searchValue+"&startTime="+startTime+"&endTime="+endTime+"&offset="+pre, "GET", function(response){$( "#sale-history-paginated .end" ).text(+end - +10);$( "#sale-history-paginated .start" ).text(+start - +10);$('#sale-history-table').html(response);$("#sale-history-paginated .next").prop('disabled', false);if (parseInt(pre)==0){$("#sale-history-paginated .previous").prop('disabled', true);}});}function loadSaleDetails(orderId, domId){doAjaxRequestHandler(context+"/saleDetails?orderId="+orderId, "GET", function(response){$('#' + domId).html(response);});}function saleHistory(domId, searchType, searchValue, startTime, endTime){doAjaxRequestHandler(context+"/saleHistory?searchType="+searchType+"&searchValue="+searchValue+"&startTime="+startTime+"&endTime="+endTime, "GET", function(response){$('#' + domId).html(response);});}function saleHistorySearchInfo(searchType, searchText, startTime, endTime){saleHistory("main-content", searchType, searchText, startTime, endTime);}