Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31816 tejbeer 1
$(function() {
2
	$(document).on('click', ".brand-region-mapping", function() {
3
		loadBrandRegionMapping("main-content");
4
	});
5
 
6
 
7
	$(document).on('click', ".region-brand-mapping", function() {
8
 
9
		var brand = $('#regionBrand').val();
10
 
11
		var accessory = $('#accessory').is(':checked');
12
 
13
 
14
 
15
		doGetAjaxRequestHandler(context + "/getBrandRegionMapping?brand=" + brand + "&accessory=" + accessory, function(response) {
16
 
17
			$('.brandRegionMappingContainer').html(response);
18
		});
19
	});
20
 
21
	$(document).on('click', ".remove-mapping", function() {
22
		var brand = $(this).data('brand');
23
		var fromWarehouse = $(this).data('fromwarehouse');
24
		var toWarehouse = $(this).data('towarehouse');
25
		var accessory = $(this).data('isaccessory');
26
		var row = $(this).closest("tr");
27
 
28
		var brandRegionModel = {};
29
		brandRegionModel['brand'] = brand;
30
		brandRegionModel['fromWarehouse'] = fromWarehouse
31
		brandRegionModel['toWarehouse'] = toWarehouse
32
		brandRegionModel['accessory'] = accessory
33
 
34
 
35
 
36
		doPostAjaxRequestWithJsonHandler(context + "/removeBrandRegionMapping", JSON
37
			.stringify(brandRegionModel), function(response) {
38
				if (response == "true") {
39
					alert("Mapping removed successfully");
40
 
41
					doGetAjaxRequestHandler(context + "/getBrandRegionMapping?brand=" + brand + "&accessory=" + accessory, function(response) {
42
 
43
						$('.brandRegionMappingContainer').html(response);
44
					});
45
				}
46
			});
47
	});
48
 
49
 
50
 
51
 
52
	$(document).on('click', ".mapping-submit", function() {
53
 
54
		var brand = $('#regionBrand').val();
55
		var fromWarehouse = $('#fromWarehouse').val();
56
 
57
		var toWarehouse = $('#toWarehouse').val();
58
 
59
		var accessory = $('#accessory').is(':checked');
60
 
61
 
62
 
63
		if (brand == "" || brand == null
64
			|| brand == undefined) {
65
			alert("please select brand");
66
			return false;
67
		}
68
		if (fromWarehouse == "" || fromWarehouse == null
69
			|| fromWarehouse == undefined) {
70
			alert("please select from warehouse");
71
			return false;
72
		}
73
 
74
		if (toWarehouse == "" || toWarehouse == null
75
			|| toWarehouse == undefined) {
76
			alert("please select toWarehouse");
77
			return false;
78
		}
79
 
80
 
81
 
82
		var brandRegionMappingModel = {};
83
		brandRegionMappingModel['accessory'] = accessory
84
 
85
		brandRegionMappingModel['brand'] = brand
86
		brandRegionMappingModel['fromWarehouse'] = fromWarehouse
87
		brandRegionMappingModel['toWarehouse'] = toWarehouse
88
 
89
 
90
		console.log(brandRegionMappingModel);
91
 
92
		console.log(JSON
93
			.stringify(brandRegionMappingModel));
94
		doPostAjaxRequestWithJsonHandler(context + "/brandRegionMapped", JSON
95
			.stringify(brandRegionMappingModel), function(response) {
96
				if (response == "true") {
97
					alert("Mapping created successfully");
98
 
99
					doGetAjaxRequestHandler(context + "/getBrandRegionMapping?brand=" + brand + "&accessory=" + accessory, function(response) {
100
 
101
						$('.brandRegionMappingContainer').html(response);
102
					});
103
				}
104
			});
105
	});
106
 
107
});
108
 
109
function loadBrandRegionMapping(domId) {
110
 
111
	doGetAjaxRequestHandler(context + "/brandRegionMapping", function(response) {
112
		$('#' + domId).html(response);
113
	});
114
}