Subversion Repositories SmartDukaan

Rev

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

Rev 1035 Rev 1048
Line 53... Line 53...
53
*/
53
*/
54
function countOtherAddress(){
54
function countOtherAddress(){
55
	var i 			= 0;
55
	var i 			= 0;
56
	var count 		= 2;
56
	var count 		= 2;
57
	var addressID 	= 0;
57
	var addressID 	= 0;
58
	var arrAddressID = new Array();
58
	var arrAddressID = [];
59
	var otherAddressCount = 0;
59
	var otherAddressCount = 0;
60
	
60
	
61
	if ($("#shippingAddress #A1 div").attr("id") != undefined) {
61
	if ($("#shippingAddress #A1 div").attr("id") != undefined) {
62
		addressID = parseInt($("#shippingAddress #A1 div").attr("id").substr(7));
62
		addressID = parseInt($("#shippingAddress #A1 div").attr("id").substr(7));
63
		arrAddressID.push(addressID);
63
		arrAddressID.push(addressID);
64
	}
64
	}
65
	
65
	
66
	while(i == 0){
66
	while(i === 0){
67
		if($("#shippingAddress").find("#A" + count + ":visible").length == 1){
67
		if($("#shippingAddress").find("#A" + count + ":visible").length == 1){
68
			addressID = parseInt($("#shippingAddress").find("#A" + count + " div").attr("id").substr(7));
68
			addressID = parseInt($("#shippingAddress").find("#A" + count + " div").attr("id").substr(7));
69
			arrAddressID.push(addressID);
69
			arrAddressID.push(addressID);
70
			
70
			
71
			otherAddressCount++;	// Count of other addresses
71
			otherAddressCount++;	// Count of other addresses
Line 95... Line 95...
95
	Invoked on "Make Primary Address" btn click
95
	Invoked on "Make Primary Address" btn click
96
*/
96
*/
97
function makePriAddress(sourceId){
97
function makePriAddress(sourceId){
98
	//alert("ajax to make primary "+ sourceId.substring(7,sourceId.length));
98
	//alert("ajax to make primary "+ sourceId.substring(7,sourceId.length));
99
	ajaxMakePrimary(sourceId.substring(7,sourceId.length));
99
	ajaxMakePrimary(sourceId.substring(7,sourceId.length));
100
	
100
    var destId="";
-
 
101
    var destAddress="";
101
	// if primary address is present then take backup of primary id and address
102
	// if primary address is present then take backup of primary id and address
102
	if($(".noAddress1:visible").length != 1){
103
	if($(".noAddress1:visible").length != 1){
103
		var destId 		= $("#A1 div").attr("id");
104
		destId 		= $("#A1 div").attr("id");
104
		var destAddress = $("#" + destId + " .address").html();
105
		destAddress = $("#" + destId + " .address").html();
105
	}
106
	}
106
	
107
	
107
	var sourceIdParentId 	= $("#" + sourceId).parent().attr("id");
108
	var sourceIdParentId 	= $("#" + sourceId).parent().attr("id");
108
	var sourceAddress 		= $("#" + sourceId + " .address").html();
109
	var sourceAddress 		= $("#" + sourceId + " .address").html();
109
	
110
	
Line 163... Line 164...
163
			
164
			
164
		
165
		
165
		alert("Ajax call to delete" + sourceId);
166
		alert("Ajax call to delete" + sourceId);
166
		
167
		
167
		// make first other address as primary address if available
168
		// make first other address as primary address if available
168
		if(otherAddressCount == 0){
169
		if(otherAddressCount === 0){
169
			$("#" + sourceIdParentId).html("");
170
			$("#" + sourceIdParentId).html("");
170
			$(".noAddress1").slideDown('slow');
171
			$(".noAddress1").slideDown('slow');
171
		}else{
172
		}else{
172
			
173
			
173
			// make first other address to primary and delete that
174
			// make first other address to primary and delete that
174
			var destId = $("#A1 div").attr("id");
175
			var destId = $("#A1 div").attr("id");
175
			
176
			
176
			var sourceIdParentId = $("#addressContainer div").attr("id");
177
			sourceIdParentId = $("#addressContainer div").attr("id");
177
			sourceId = $("#" + sourceIdParentId + " div").attr("id");		
178
			sourceId = $("#" + sourceIdParentId + " div").attr("id");		
178
 
179
 
179
			var sourceAddress = $("#" + sourceId + " .address").html();
180
			var sourceAddress = $("#" + sourceId + " .address").html();
180
			
181
			
181
			// Replace destination Id and its content with source
182
			// Replace destination Id and its content with source
Line 207... Line 208...
207
	
208
	
208
	$("#" + sourceIdParentId).slideUp('slow', function(){
209
	$("#" + sourceIdParentId).slideUp('slow', function(){
209
		$(this).remove();
210
		$(this).remove();
210
		otherAddressCount--;
211
		otherAddressCount--;
211
		
212
		
212
		if(otherAddressCount == 0){
213
		if(otherAddressCount === 0){
213
			$(".noAddress2").slideDown('slow');
214
			$(".noAddress2").slideDown('slow');
214
		}
215
		}
215
	});
216
	});
216
}
217
}
217
 
218
 
Line 227... Line 228...
227
	var cityVal 	= $("#shippingAddress #txtCity").val();
228
	var cityVal 	= $("#shippingAddress #txtCity").val();
228
	var pinCodeVal  = jQuery.trim($("#shippingAddress #txtPinCode").val());
229
	var pinCodeVal  = jQuery.trim($("#shippingAddress #txtPinCode").val());
229
	var phoneVal	= jQuery.trim($("#shippingAddress #txtPhone").val());
230
	var phoneVal	= jQuery.trim($("#shippingAddress #txtPhone").val());
230
 
231
 
231
		
232
		
232
	if(nameVal.length == 0){
233
	if(nameVal.length === 0){
233
		alert("Please enter name.");
234
		alert("Please enter name.");
234
		
235
		
235
		$("#shippingAddress #txtName").focus();
236
		$("#shippingAddress #txtName").focus();
236
		return false;	
237
		return false;	
237
	}else if(add1Val.length == 0){
238
	}else if(add1Val.length === 0){
238
		alert("Please enter address.");
239
		alert("Please enter address.");
239
		
240
		
240
		$("#shippingAddress #txtAddress").focus();
241
		$("#shippingAddress #txtAddress").focus();
241
		return false;	
242
		return false;	
242
	}else if(stateVal == "0"){
243
	}else if(stateVal == "0"){
243
		alert("Please select state.");
244
		alert("Please select state.");
244
		
245
		
245
		$("#shippingAddress #state").focus();
246
		$("#shippingAddress #state").focus();
246
		return false;	
247
		return false;	
247
	}else if(phoneVal.length == 0){
248
	}else if(phoneVal.length === 0){
248
		alert("Please enter phone no.");
249
		alert("Please enter phone no.");
249
		
250
		
250
		$("#shippingAddress #txtPhone").focus();
251
		$("#shippingAddress #txtPhone").focus();
251
		return false;		
252
		return false;		
252
	}else if(pinCodeVal.length == 0){
253
	}else if(pinCodeVal.length == 0){
Line 273... Line 274...
273
 
274
 
274
/**
275
/**
275
	Invoke from saveAddress() function
276
	Invoke from saveAddress() function
276
*/
277
*/
277
function addPriAddress(){
278
function addPriAddress(){
278
	
-
 
-
 
279
    var priAddressID = "";
-
 
280
    var priAddress = "";
279
	// if primary address is present then take backup of primary id and address to make as first other id and address
281
	// if primary address is present then take backup of primary id and address to make as first other id and address
280
	if($(".noAddress1:visible").length != 1){
282
	if($(".noAddress1:visible").length != 1){
281
		var priAddressID 	= $("#A1 div").attr("id");
283
		priAddressID 	= $("#A1 div").attr("id");
282
		var priAddress 		= $("#" + priAddressID + " .address").html();
284
		priAddress	= $("#" + priAddressID + " .address").html();
283
	}
285
	}
284
 
286
 
285
	var priName 	= $("#shippingAddress #txtName").val();
287
	var priName 	= $("#shippingAddress #txtName").val();
286
	var priAdd1 	= $("#shippingAddress #txtAddress").val();
288
	var priAdd1 	= $("#shippingAddress #txtAddress").val();
287
	var priAdd2 	= $("#shippingAddress #txtAddress2").val();
289
	var priAdd2 	= $("#shippingAddress #txtAddress2").val();
Line 291... Line 293...
291
	var priPhone 	= $("#shippingAddress #txtPhone").val();
293
	var priPhone 	= $("#shippingAddress #txtPhone").val();
292
	var priEmail = "";
294
	var priEmail = "";
293
	
295
	
294
	var newPriAddressID	= "address" + (++lastAddressID);	// create new primary id to get newly inserted data from form	
296
	var newPriAddressID	= "address" + (++lastAddressID);	// create new primary id to get newly inserted data from form	
295
 
297
 
296
	var newPriAddress = priName + "<br />" + priAdd1 + "<br />" + priAdd2 + "<br />" + priCity + "<br />" 
298
	var newPriAddress = priName + "<br />" + priAdd1 + "<br />" + priAdd2 + "<br />" + priCity + "<br />" + priPinCode + "<br />" + priState + "<br /> Phone: " + priPhone ;
297
	+ priPinCode + "<br />" + priState + "<br /> Phone: " + priPhone ;
-
 
298
	
299
	
299
	// if primary address is present then add new primary address and shift old primary address as first other address
300
	// if primary address is present then add new primary address and shift old primary address as first other address
300
	if($(".noAddress1:visible").length != 1){
301
	if($(".noAddress1:visible").length != 1){
301
		$("#A1 #" + priAddressID).attr("id", newPriAddressID);
302
		$("#A1 #" + priAddressID).attr("id", newPriAddressID);
302
		$("#A1 #" + newPriAddressID + " .address").html(newPriAddress);
303
		$("#A1 #" + newPriAddressID + " .address").html(newPriAddress);
Line 524... Line 525...
524
		  success: function(msg){
525
		  success: function(msg){
525
			  //alert( "Data Saved: " + msg );
526
			  //alert( "Data Saved: " + msg );
526
			   //	$("#addressid").val(msg);
527
			   //	$("#addressid").val(msg);
527
		  }
528
		  }
528
	});
529
	});
529
}
-
 
530
530
}
-
 
531