Subversion Repositories SmartDukaan

Rev

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

Rev 30084 Rev 30148
Line 60... Line 60...
60
			event.preventDefault();
60
			event.preventDefault();
61
			if(validateSchemeDetails()){
61
			if(validateSchemeDetails()){
62
				alert("Please fix errors");
62
				alert("Please fix errors");
63
				return false;
63
				return false;
64
			}
64
			}
65
			var json = schemeDetailsJson();
65
			let json = schemeDetailsJson();
66
			console.log("schemeJson = " + json);
66
			console.log("schemeJson = " + json);
67
			if(confirm("Are you sure you want to create Scheme!") == true){
67
			if(confirm("Are you sure you want to create Scheme!") == true){
68
				doPostAjaxRequestWithJsonHandler(context+"/createScheme", json, function(response){
68
				doPostAjaxRequestWithJsonHandler(context+"/createScheme", json, function(response){
69
					$('#main-content').html(response);
69
					$('#main-content').html(response);
70
				});
70
				});
Line 126... Line 126...
126
		alert("Amount should be greater than 0");
126
		alert("Amount should be greater than 0");
127
		$("#schemeAmount").addClass("border-highlight");
127
		$("#schemeAmount").addClass("border-highlight");
128
		error = true;
128
		error = true;
129
		return error;
129
		return error;
130
	}
130
	}
131
	
131
 
132
	
132
 
133
	//$('#brand-value').text($(this).text());
133
	//$('#brand-value').text($(this).text());
134
	$("#tag-listing-brand-value").removeClass("border-highlight");
134
	$("#tag-listing-brand-value").removeClass("border-highlight");
135
	if($("#tag-listing-brand-value").text() == "Brands"){
135
	if ($("#tag-listing-brand-value").text() == "Brands") {
136
		alert("Please choose Brand");
136
		alert("Please choose Brand");
137
		$("#tag-listing-brand-value").addClass("border-highlight");
137
		$("#tag-listing-brand-value").addClass("border-highlight");
138
		error = true;
138
		error = true;
139
		return error;
139
		return error;
140
	}
140
	}
141
	
141
 
142
	$("select.tagListingItemsDescription").removeClass("border-hightlight");
142
	$("select.catalogItemsDescription").removeClass("border-hightlight");
143
	var itemIdsString = $("select.tagListingItemsDescription").val();
143
	var itemIdsString = $("select.catalogItemsDescription").val();
144
	debugger;
144
	debugger;
145
	if(itemIdsString == null){
145
	if (itemIdsString == null) {
146
		alert("Please choose items");
146
		alert("Please choose items");
147
		$("select.tagListingItemsDescription").addClass("border-highlight");
147
		$("select.catalogItemsDescription").addClass("border-highlight");
148
		error = true;
148
		error = true;
149
		return error;
149
		return error;
150
	}
150
	}
151
		
151
 
152
	console.log("validation scheme error = " + error);
152
	console.log("validation scheme error = " + error);
153
	return error;
153
	return error;
154
}
154
}
155
 
155
 
156
function schemeDetailsJson(){
156
function schemeDetailsJson(){
157
	console.log("schemeDetailsJson")
-
 
158
	var schemeObject = {};
157
	var schemeObject = {};
159
	schemeObject['name'] = $("form#create-scheme-form input[name=schemeName]").val();
158
	schemeObject['name'] = $("form#create-scheme-form input[name=schemeName]").val();
160
	schemeObject['description'] = $("form#create-scheme-form input[name=description]").val();
159
	schemeObject['description'] = $("form#create-scheme-form input[name=description]").val();
161
	schemeObject['type'] = $("#schemeType option:selected").val();
160
	schemeObject['type'] = $("#schemeType option:selected").val();
162
	schemeObject['amountType'] = $("#amountType option:selected").val();
161
	schemeObject['amountType'] = $("#amountType option:selected").val();
163
	schemeObject['amount'] = $('#schemeAmount').val();
162
	schemeObject['amount'] = $('#schemeAmount').val();
164
	schemeObject['partnerType'] = $('#retailerType').val();
163
	schemeObject['partnerType'] = $('#retailerType').val();
165
	schemeObject['cashback'] = $("#cashbackScheme").is(":checked")
164
	schemeObject['cashback'] = $("#cashbackScheme").is(":checked")
166
	schemeObject['startDate'] = $("#schemeDuration").data('daterangepicker').startDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
165
	schemeObject['startDate'] = $("#schemeDuration").data('daterangepicker').startDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
167
	schemeObject['endDate'] = $("#schemeDuration").data('daterangepicker').endDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
166
	schemeObject['endDate'] = $("#schemeDuration").data('daterangepicker').endDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
168
	schemeObject['itemIds'] = [];
167
	schemeObject['catalogIds'] = [];
169
	var itemIds = $("select.tagListingItemsDescription").val();
168
	schemeObject['catalogIds'] = $("select.catalogItemsDescription").val();
170
	//var itemIds = itemIdsString.substring(1, itemIdsString.length - 1).split(",");
-
 
171
	for (var i = 0; i < itemIds.length; i++) {
-
 
172
		schemeObject['itemIds'].push(parseInt(itemIds[i]));
-
 
173
	}
-
 
174
	return JSON.stringify(schemeObject);
169
	return JSON.stringify(schemeObject);
175
}
170
}
176
171