Subversion Repositories SmartDukaan

Rev

Rev 22956 | Rev 23026 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22956 Rev 22982
Line 40... Line 40...
40
}
40
}
41
 
41
 
42
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
42
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
43
	//$( ".log" ).text( "Triggered ajaxError handler." );
43
	//$( ".log" ).text( "Triggered ajaxError handler." );
44
	if(jqxhr.status == 400){
44
	if(jqxhr.status == 400){
45
		$('#error-prompt-model').modal();
45
		//$('#error-prompt-model').modal();
46
		badRequestAlert(jqxhr);	
46
		badRequestAlert(jqxhr);	
47
	}else{
47
	}else{
48
		internalServerErrorAlert(jqxhr);
48
		internalServerErrorAlert(jqxhr);
49
	}
49
	}
50
});
50
});
51
 
51
 
-
 
52
function doAjaxRequest(urlString, httpType, callback_function){
-
 
53
	$.ajax({
-
 
54
	   url: urlString,
-
 
55
	   async: false,
-
 
56
	   type: httpType,
-
 
57
	   success: function(response) {
-
 
58
	      //console.log("response"+JSON.stringify(data));
-
 
59
	      callback_function(response);
-
 
60
	   }
-
 
61
	});
-
 
62
}
-
 
63
 
-
 
64
function doAjaxUploadRequest(urlString, httpType, file, callback_function){
-
 
65
	var formData = new FormData();
-
 
66
	formData.append("file", file);
-
 
67
	$.ajax({
-
 
68
	   url: urlString,
-
 
69
	   type: httpType,
-
 
70
	   data: formData,
-
 
71
       dataType: 'json',
-
 
72
       async: true,
-
 
73
       cache: false,
-
 
74
       contentType: false,
-
 
75
       enctype: 'multipart/form-data',
-
 
76
       processData: false,
-
 
77
	   success: function(response) {
-
 
78
	      //console.log("response"+JSON.stringify(data));
-
 
79
	      callback_function(response);
-
 
80
	   }
-
 
81
	});
-
 
82
}
-
 
83
 
-
 
84
function uploadDocument(file){
-
 
85
	var url = '/profitmandi-web/document-upload';
-
 
86
	var response;
-
 
87
	doAjaxUploadRequest(url, 'POST', file, function(ajaxResponse){
-
 
88
		response = ajaxResponse;
-
 
89
	});
-
 
90
	var documentId = response.response.document_id; 
-
 
91
	console.log("documentId : "+documentId);
-
 
92
	return documentId;
-
 
93
}
-
 
94
 
-
 
95
function uploadRetailerDocument(divId, file, emailIdOrMobileNumber){
-
 
96
	var url = '/profitmandi-web/document-upload';
-
 
97
	//var response;
-
 
98
	doAjaxUploadRequest(url, 'POST', file, function(ajaxResponse){
-
 
99
		var documentId = ajaxResponse.response.document_id; 
-
 
100
		console.log("documentId : "+documentId);
-
 
101
		var url = context+'/updateRetailerDocument?emailIdOrMobileNumber='+emailIdOrMobileNumber
-
 
102
	    +'&documentId='+documentId;
-
 
103
		var response;
-
 
104
		doAjaxRequest(url, 'PUT', function(ajaxResponse){
-
 
105
			response = ajaxResponse;
-
 
106
		});
-
 
107
		$('#' + divId).html(response);
-
 
108
		alert("Retailer Document has been updated.");
-
 
109
	});
-
 
110
}
-
 
111
 
-
 
112
function uploadRetailerShopDocument(divId, file, emailIdOrMobileNumber, shopId){
-
 
113
	//var documentId = uploadDocument(file);
-
 
114
	var url = '/profitmandi-web/document-upload';
-
 
115
	//var response;
-
 
116
	doAjaxUploadRequest(url, 'POST', file, function(ajaxResponse){
-
 
117
		var documentId = ajaxResponse.response.document_id; 
-
 
118
		console.log("documentId : "+documentId);
-
 
119
		var url = context+'/updateRetailerShopDocument?emailIdOrMobileNumber='+emailIdOrMobileNumber
-
 
120
	    +'&shopId='+shopId
-
 
121
	    +'&documentId='+documentId;
-
 
122
		var response;
-
 
123
		doAjaxRequest(url, 'PUT', function(ajaxResponse){
-
 
124
			response = ajaxResponse;
-
 
125
		});
-
 
126
		$('#' + divId).html(response);
-
 
127
		alert("Retailer Shop Document has been updated.");
-
 
128
	});
-
 
129
	
-
 
130
}
-
 
131
 
-
 
132
 
52
function attachSignin(element) {
133
function attachSignin(element) {
53
    console.log(element.id);
134
    console.log(element.id);
54
    auth2.attachClickHandler(element, {},
135
    auth2.attachClickHandler(element, {},
55
        function(googleUser) {
136
        function(googleUser) {
56
    		googleProfile = googleUser.getBasicProfile();
137
    		googleProfile = googleUser.getBasicProfile();
Line 124... Line 205...
124
            $('#' + domId).html(response);
205
            $('#' + domId).html(response);
125
        }
206
        }
126
    });  
207
    });  
127
}
208
}
128
 
209
 
-
 
210
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber){
-
 
211
	jQuery.ajax({
-
 
212
        type : "GET",
-
 
213
        url : context+"/retailerDetail/?emailIdOrMobileNumber="+emailIdOrMobileNumber,
-
 
214
        success : function(response) {
-
 
215
            $('#' + domId).html(response);
-
 
216
        }
-
 
217
    }); 
-
 
218
}
-
 
219
 
129
function downloadAgingReport(){
220
function downloadAgingReport(){
130
	data = JSON.stringify([5,15,30,45]),
221
	data = JSON.stringify([5,15,30,45]),
131
	xhttp = new XMLHttpRequest();
222
	xhttp = new XMLHttpRequest();
132
	xhttp.onreadystatechange = function() {
223
	xhttp.onreadystatechange = function() {
133
	    var a;
224
	    var a;
Line 751... Line 842...
751
        success : function(response) {
842
        success : function(response) {
752
        	$('#main-content').html(response);
843
        	$('#main-content').html(response);
753
        }
844
        }
754
    });
845
    });
755
}
846
}
-
 
847
 
-
 
848
function retailerInfo(domId){
-
 
849
	jQuery.ajax({
-
 
850
        type : "GET",
-
 
851
        url : context+"/retailerInfo",
-
 
852
        success : function(response) {
-
 
853
        	$('#main-content').html(response);
-
 
854
        }
-
 
855
    });
-
 
856
}
756
 
857
 
757
function redirectCart(url, cartData, method, domId){
858
function redirectCart(url, cartData, method, domId){
758
	jQuery.ajax({
859
	jQuery.ajax({
759
        type : method,
860
        type : method,
760
        data: {"cartData":cartData},
861
        data: {"cartData":cartData},