Subversion Repositories SmartDukaan

Rev

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

Rev 22071 Rev 22073
Line 1... Line -...
1
var context = "/profitmandi-fofo";
-
 
2
var googleProfile;
1
var googleProfile;
3
 
2
 
4
var startApp = function() {
3
var startApp = function() {
5
  gapi.load('auth2', function(){
4
  gapi.load('auth2', function(){
6
    // Retrieve the singleton for the GoogleAuth library and set up the client.
5
    // Retrieve the singleton for the GoogleAuth library and set up the client.
Line 27... Line 26...
27
  }
26
  }
28
 
27
 
29
function submitUser(googleUser){
28
function submitUser(googleUser){
30
	jQuery.ajax({
29
	jQuery.ajax({
31
        type : "POST",
30
        type : "POST",
32
        url : context+"/login",
31
        url : context+"login",
33
        data: {"token":googleUser.getAuthResponse().id_token},
32
        data: {"token":googleUser.getAuthResponse().id_token},
34
        success: function(data, textStatus, request){
33
        success: function(data, textStatus, request){
35
        	console.log(data);
34
        	console.log(data);
36
        	addProfileInLocalDb();
35
        	addProfileInLocalDb();
37
        	window.location.href= "/profitmandi-fofo/dashboard";
36
        	window.location.href= context + "dashboard";
38
   		}
37
   		}
39
    });  
38
    });  
40
}
39
}
41
 
40
 
42
function addProfileInLocalDb(){
41
function addProfileInLocalDb(){
Line 46... Line 45...
46
 
45
 
47
 
46
 
48
function loadNewGrn(domId){
47
function loadNewGrn(domId){
49
	jQuery.ajax({
48
	jQuery.ajax({
50
        type : "GET",
49
        type : "GET",
51
        url : context+"/purchase",
50
        url : context + "purchase",
52
        success : function(response) {
51
        success : function(response) {
53
            $('#' + domId).html(response);
52
            $('#' + domId).html(response);
54
        }
53
        }
55
    });  
54
    });  
56
}
55
}
57
 
56
 
58
function loadGoodInventory(domId, search_text){
57
function loadGoodInventory(domId, search_text){
59
	jQuery.ajax({
58
	jQuery.ajax({
60
        type : "GET",
59
        type : "GET",
61
        url : context+"/getCurrentInventorySnapshot/?searchTerm="+search_text,
60
        url : context + "getCurrentInventorySnapshot/?searchTerm="+search_text,
62
        success : function(response) {
61
        success : function(response) {
63
            $('#' + domId).html(response);
62
            $('#' + domId).html(response);
64
        }
63
        }
65
    });  
64
    });  
66
}
65
}
67
 
66
 
68
function loadCatalog(domId, search_text){
67
function loadCatalog(domId, search_text){
69
	jQuery.ajax({
68
	jQuery.ajax({
70
        type : "GET",
69
        type : "GET",
71
        url : context+"/getCatalog/?searchTerm="+search_text,
70
        url : context + "getCatalog/?searchTerm="+search_text,
72
        success : function(response) {
71
        success : function(response) {
73
            $('#' + domId).html(response);
72
            $('#' + domId).html(response);
74
        }
73
        }
75
    });  
74
    });  
76
}
75
}
77
 
76
 
78
function loadBadInventory(domId, search_text){
77
function loadBadInventory(domId, search_text){
79
	jQuery.ajax({
78
	jQuery.ajax({
80
        type : "GET",
79
        type : "GET",
81
        url : context+"/getBadInventorySnapshot/?searchTerm="+search_text,
80
        url : context+"getBadInventorySnapshot/?searchTerm="+search_text,
82
        success : function(response) {
81
        success : function(response) {
83
            $('#' + domId).html(response);
82
            $('#' + domId).html(response);
84
        }
83
        }
85
    });  
84
    });  
86
}
85
}
87
 
86
 
88
function loadGrnHistory(domId,purchase_reference,searchType, startTime, endTime){
87
function loadGrnHistory(domId,purchase_reference,searchType, startTime, endTime){
89
	jQuery.ajax({
88
	jQuery.ajax({
90
        type : "GET",
89
        type : "GET",
91
        url : context+"/grnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
90
        url : context+"grnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
92
        +"&startTime="+startTime
91
        +"&startTime="+startTime
93
        +"&endTime="+endTime,
92
        +"&endTime="+endTime,
94
        success : function(response) {
93
        success : function(response) {
95
            $('#' + domId).html(response);
94
            $('#' + domId).html(response);
96
        }
95
        }
Line 102... Line 101...
102
	console.log(end);
101
	console.log(end);
103
	console.log(+end + +10);
102
	console.log(+end + +10);
104
	console.log(+start + +10);
103
	console.log(+start + +10);
105
	jQuery.ajax({
104
	jQuery.ajax({
106
	        type : "GET",
105
	        type : "GET",
107
	        url : context+"/getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText,
106
	        url : context+"getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText,
108
			beforeSend: function(){
107
			beforeSend: function(){
109
	        //$('#ajax-spinner').show();
108
	        //$('#ajax-spinner').show();
110
	        },
109
	        },
111
	        complete: function(){
110
	        complete: function(){
112
	        //$('#ajax-spinner').hide();
111
	        //$('#ajax-spinner').hide();
Line 129... Line 128...
129
	    });  
128
	    });  
130
	}
129
	}
131
function getPreviousItems(start,end,pre,searchText){
130
function getPreviousItems(start,end,pre,searchText){
132
	jQuery.ajax({
131
	jQuery.ajax({
133
	        type : "GET",
132
	        type : "GET",
134
	        url : context+"/getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText,
133
	        url : context+"getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText,
135
			beforeSend: function(){
134
			beforeSend: function(){
136
	        //$('#ajax-spinner').show();
135
	        //$('#ajax-spinner').show();
137
	        },
136
	        },
138
	        complete: function(){
137
	        complete: function(){
139
	        //$('#ajax-spinner').hide();
138
	        //$('#ajax-spinner').hide();
Line 160... Line 159...
160
	console.log(end);
159
	console.log(end);
161
	console.log(+end + +10);
160
	console.log(+end + +10);
162
	console.log(+start + +10);
161
	console.log(+start + +10);
163
	jQuery.ajax({
162
	jQuery.ajax({
164
	        type : "GET",
163
	        type : "GET",
165
	        url : context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
164
	        url : context+"getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
166
	        +"&startTime="+startTime
165
	        +"&startTime="+startTime
167
	        +"&endTime="+endTime+"&offset="+end,
166
	        +"&endTime="+endTime+"&offset="+end,
168
			beforeSend: function(){
167
			beforeSend: function(){
169
	        //$('#ajax-spinner').show();
168
	        //$('#ajax-spinner').show();
170
	        },
169
	        },
Line 189... Line 188...
189
	    });  
188
	    });  
190
	}
189
	}
191
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
190
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
192
	jQuery.ajax({
191
	jQuery.ajax({
193
	        type : "GET",
192
	        type : "GET",
194
	        url : context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
193
	        url : context+"getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
195
	        +"&startTime="+startTime
194
	        +"&startTime="+startTime
196
	        +"&endTime="+endTime+"&offset="+pre,
195
	        +"&endTime="+endTime+"&offset="+pre,
197
			beforeSend: function(){
196
			beforeSend: function(){
198
	        //$('#ajax-spinner').show();
197
	        //$('#ajax-spinner').show();
199
	        },
198
	        },
Line 231... Line 230...
231
}
230
}
232
 
231
 
233
function loadGrnDetails(purchaseId,domId){
232
function loadGrnDetails(purchaseId,domId){
234
	jQuery.ajax({
233
	jQuery.ajax({
235
        type : "GET",
234
        type : "GET",
236
        url : context+"/grnHistoryDetailByPurchaseId/?purchaseId="+purchaseId,
235
        url : context+"grnHistoryDetailByPurchaseId/?purchaseId="+purchaseId,
237
        success : function(response) {
236
        success : function(response) {
238
            $('#' + domId).html(response);
237
            $('#' + domId).html(response);
239
            window.dispatchEvent(new Event('resize'));
238
            window.dispatchEvent(new Event('resize'));
240
        }
239
        }
241
    });
240
    });
242
}
241
}
243
 
242
 
244
function loadPendingGrnDetails(purchaseId,domId){
243
function loadPendingGrnDetails(purchaseId,domId){
245
	jQuery.ajax({
244
	jQuery.ajax({
246
		url: context+"/purchase/?airwayBillOrInvoiceNumber="+purchaseId,
245
		url: context+"purchase/?airwayBillOrInvoiceNumber="+purchaseId,
247
		type: 'POST',
246
		type: 'POST',
248
		async: false,
247
		async: false,
249
		success: function (data) {
248
		success: function (data) {
250
			$('#'+domId).html(data);
249
			$('#'+domId).html(data);
251
		},
250
		},
Line 263... Line 262...
263
	console.log(end);
262
	console.log(end);
264
	console.log(+end + +10);
263
	console.log(+end + +10);
265
	console.log(+start + +10);
264
	console.log(+start + +10);
266
	jQuery.ajax({
265
	jQuery.ajax({
267
	        type : "GET",
266
	        type : "GET",
268
	        url : context+"/getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText,
267
	        url : context+"getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText,
269
			beforeSend: function(){
268
			beforeSend: function(){
270
	        //$('#ajax-spinner').show();
269
	        //$('#ajax-spinner').show();
271
	        },
270
	        },
272
	        complete: function(){
271
	        complete: function(){
273
	        //$('#ajax-spinner').hide();
272
	        //$('#ajax-spinner').hide();
Line 289... Line 288...
289
	    });  
288
	    });  
290
	}
289
	}
291
function getPreviousCatalogItems(start,end,pre,searchText){
290
function getPreviousCatalogItems(start,end,pre,searchText){
292
	jQuery.ajax({
291
	jQuery.ajax({
293
	        type : "GET",
292
	        type : "GET",
294
	        url : context+"/getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText,
293
	        url : context+"getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText,
295
			beforeSend: function(){
294
			beforeSend: function(){
296
	        //$('#ajax-spinner').show();
295
	        //$('#ajax-spinner').show();
297
	        },
296
	        },
298
	        complete: function(){
297
	        complete: function(){
299
	        //$('#ajax-spinner').hide();
298
	        //$('#ajax-spinner').hide();
Line 359... Line 358...
359
 
358
 
360
function loadCart(domId){
359
function loadCart(domId){
361
	jQuery.ajax({
360
	jQuery.ajax({
362
        type : "POST",
361
        type : "POST",
363
        data: {"cartData":localStorage.getItem("bag")},
362
        data: {"cartData":localStorage.getItem("bag")},
364
        url : context+"/cart",
363
        url : context+"cart",
365
        success : function(response) {
364
        success : function(response) {
366
            $('#' + domId).html(response);
365
            $('#' + domId).html(response);
367
        }
366
        }
368
    });  
367
    });  
369
}
368
}
370
 
369
 
371
function checkout(domId){
370
function checkout(domId){
372
	jQuery.ajax({
371
	jQuery.ajax({
373
        type : "POST",
372
        type : "POST",
374
        data: {"cartData":localStorage.getItem("bag")},
373
        data: {"cartData":localStorage.getItem("bag")},
375
        url : context+"/validate-cart",
374
        url : context+"validate-cart",
376
        success : function(response) {
375
        success : function(response) {
377
        	var obj = JSON.parse(response);
376
        	var obj = JSON.parse(response);
378
        	redirectCart(obj.redirectUrl, obj.params, obj.method, "main-content");
377
        	redirectCart(obj.redirectUrl, obj.params, obj.method, "main-content");
379
        }
378
        }
380
    });  
379
    });