Subversion Repositories SmartDukaan

Rev

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

Rev 26805 Rev 26817
Line 118... Line 118...
118
	});
118
	});
119
	
119
	
120
	$('button.new-address-btn').live('click', function() {
120
	$('button.new-address-btn').live('click', function() {
121
		$('#newaddressModal').modal({show: true});
121
		$('#newaddressModal').modal({show: true});
122
	});
122
	});
-
 
123
	
-
 
124
	$('button.mk_add_customer').live('click', function() {
-
 
125
		customerObj = {}
-
 
126
		customerObj['firstName'] = $("input.firstName").val();
-
 
127
		customerObj['lastName'] = $("input.lastName").val();
-
 
128
		customerObj['emailId'] = $("#email").val();
-
 
129
		customerObj['mobileNumber'] = $("input.phone").val();
-
 
130
		doPostAjaxRequestWithJsonHandler(`${context}/customer/add`, JSON.stringify(customerObj), function(response){
-
 
131
			alert("Customer added");
-
 
132
			$( "input.search-phone").val(customerObj['mobileNumber']).change();
-
 
133
		});
-
 
134
		
-
 
135
		
-
 
136
	});
-
 
137
	$('a.select-address').live('click', function() {
-
 
138
		$(this).closest('table').data("addressselected", "true").find('td').css("font-weight", "normal");
-
 
139
		$(this).closest('tr').find('td').css("font-weight", "bold");
-
 
140
		selectedAddressId = $(this).data("addressid");
-
 
141
	});
123
	$('button.btn-add-address').live('click', function(){
142
	$('button.btn-add-address').live('click', function(){
124
		var customerAddress = {};
143
		var customerAddress = {};
125
		customerAddress['firstName'] = $("#firstName").val();
144
		customerAddress['name'] = $("#firstName").val();
126
		customerAddress['lastName'] = $("#lastName").val();
145
		customerAddress['lastName'] = $("#lastName").val();
127
		customerAddress['line1'] = $("#line1").val();
146
		customerAddress['line1'] = $("#line1").val();
128
		customerAddress['line2'] = $("#line2").val();
147
		customerAddress['line2'] = $("#line2").val();
129
		customerAddress['landmark'] = $("#landmark").val();
148
		customerAddress['landmark'] = $("#landmark").val();
130
		customerAddress['city'] = $("#city").val();
149
		customerAddress['city'] = $("#city").val();
Line 133... Line 152...
133
		customerAddress['phoneNumber'] = $("#alternatePhone").val();
152
		customerAddress['phoneNumber'] = $("#alternatePhone").val();
134
		customerAddress['country'] = "India";
153
		customerAddress['country'] = "India";
135
		console.log(customerAddress);
154
		console.log(customerAddress);
136
		doPostAjaxRequestWithJsonHandler(`${context}/customer/address?customerId=${customerId}`, JSON.stringify(customerAddress), function(response){
155
		doPostAjaxRequestWithJsonHandler(`${context}/customer/address?customerId=${customerId}`, JSON.stringify(customerAddress), function(response){
137
			$("#address-body").prepend(getAddressTr(response.response));
156
			$("#address-body").prepend(getAddressTr(response.response));
-
 
157
			$("#address-body").find('a.select-address').click();
138
		});
158
		});
139
	});
159
	});
140
	
160
	
141
}
161
}
142
function validateOrderDetails(){
162
function validateOrderDetails(){
Line 245... Line 265...
245
			tmp[itemId]  = serialNumbers;
265
			tmp[itemId]  = serialNumbers;
246
			orderObj['fofoOrderItems'] = tmp;
266
			orderObj['fofoOrderItems'] = tmp;
247
		}
267
		}
248
	});
268
	});
249
	console.log( JSON.stringify(orderObj));
269
	console.log( JSON.stringify(orderObj));
250
	$("#order-details").find("tr:not(:first-child)").each(function(index, el){
270
	$("#order-items").find("tr:not(:first-child)").each(function(index, el){
251
		// console.log(el);
271
		// console.log(el);
252
		// console.log(index);
272
		// console.log(index);
253
		var $el = $(el);
273
		var $el = $(el);
254
		var $unitPriceElement = $el.find('.unitPrice');
274
		var $unitPriceElement = $el.find('.unitPrice');
255
			
275
			
Line 275... Line 295...
275
		if(!found){
295
		if(!found){
276
			priceQtyArray.push(tmpObj);
296
			priceQtyArray.push(tmpObj);
277
		}
297
		}
278
	});	
298
	});	
279
		
299
		
280
	$("#order-details").find("tr:not(:first-child)").each(function(index,el){
300
	$("#order-items").find("tr:not(:first-child)").each(function(index,el){
281
		// console.log(el);
301
		// console.log(el);
282
		// console.log(index);
302
		// console.log(index);
283
		var $serialNumberElement = $(el).find('.serialNumber');
303
		var $serialNumberElement = $(el).find('.serialNumber');
284
		var itemId = parseInt($serialNumberElement.attr("itemId"));
304
		var itemId = parseInt($serialNumberElement.attr("itemId"));
285
		var insuranceEle = $(el).find('.insuranceamount');
305
		var insuranceEle = $(el).find('.insuranceamount');
Line 298... Line 318...
298
				'ram' :ram, 'memory' : memory, 'mfgDate':mfgdate};
318
				'ram' :ram, 'memory' : memory, 'mfgDate':mfgdate};
299
		priceQtyArray[index]['serialNumberDetails'].push(serialNumberDetails);
319
		priceQtyArray[index]['serialNumberDetails'].push(serialNumberDetails);
300
        
320
        
301
	});
321
	});
302
	
322
	
303
	customerObj['firstName'] = $("form#cd input[name=firstName]").val();
-
 
304
	customerObj['lastName'] = $("form#cd input[name=lastName]").val();
-
 
305
	customerObj['mobileNumber'] = $("form#cd input[name=phone]").val(); 
-
 
306
	customerObj['emailId'] = $("form#cd input[name=email]").val();
-
 
307
	customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
323
	customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
308
	// customerObj['dateOfBirth'] = startDate;
324
	if(customerId==undefined) {
-
 
325
		alert("Please choose customer");
-
 
326
		return false;
309
	
327
	}
310
	customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
328
	if($("#customer-address").data("addressselected")=="true") {
-
 
329
		alert("Please select address");
-
 
330
		return false;
-
 
331
	}
311
	customerObj['address'] = customerAddress; 
332
	customerObj['customerId'] = customerId; 
-
 
333
	customerObj['customerAddressId'] = selectedAddressId;
312
	customerObj['gender'] = $("#gender").val();
334
	customerObj['gender'] = $("#gender").val();
313
	customerObj['dateOfBirth'] = startDate;
335
	customerObj['dateOfBirth'] = startDate;
314
	localStorage.setItem("customerDetails", JSON.stringify(customerObj));
-
 
315
	
336
	
316
	
337
	
317
	var paymentOptionSize = parseInt($('#payment-option-id-amount-container').attr("paymentOptionSize"));
338
	var paymentOptionSize = parseInt($('#payment-option-id-amount-container').attr("paymentOptionSize"));
318
	// console.log("paymentOptionSize = "+paymentOptionSize);
339
	// console.log("paymentOptionSize = "+paymentOptionSize);
319
	for(var index = 0; index < paymentOptionSize; index++){
340
	for(var index = 0; index < paymentOptionSize; index++){
Line 325... Line 346...
325
		var paymentOptionIdAmountObject = {};
346
		var paymentOptionIdAmountObject = {};
326
		paymentOptionIdAmountObject['paymentOptionId'] = paymentOptionId;
347
		paymentOptionIdAmountObject['paymentOptionId'] = paymentOptionId;
327
		paymentOptionIdAmountObject['amount'] = paymentOptionAmount;
348
		paymentOptionIdAmountObject['amount'] = paymentOptionAmount;
328
		paymentOptionIdAmount.push(paymentOptionIdAmountObject);
349
		paymentOptionIdAmount.push(paymentOptionIdAmountObject);
329
	}
350
	}
330
	
-
 
331
	console.log( JSON.stringify(paymentOptionIdAmount));
-
 
332
	
-
 
333
	var retObj = {};
351
	var retObj = {};
334
	retObj['fofoOrderItems'] = (priceQtyArray);
352
	retObj['fofoOrderItems'] = (priceQtyArray);
335
	retObj['customer'] = (customerObj);
353
	retObj['customer'] = (customerObj);
336
	retObj['paymentOptions'] =  (paymentOptionIdAmount);
354
	retObj['paymentOptions'] =  (paymentOptionIdAmount);
337
	
355
	
Line 347... Line 365...
347
	doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
365
	doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
348
		if(response.response=='') {
366
		if(response.response=='') {
349
			return;
367
			return;
350
		}
368
		}
351
		var customer = response.response;
369
		var customer = response.response;
-
 
370
		if(customer==null) {
-
 
371
			$('input.phone').attr('value', mobileNumber).attr('readonly', true);
-
 
372
			$('button.mk_add_customer').show();
-
 
373
			
-
 
374
			return;
-
 
375
		}
-
 
376
		$('input.firstName').attr('value', customer.firstName).attr('readonly', true);
-
 
377
		$('input.lastName').attr('value', customer.lastName).attr('readonly', true);
-
 
378
		$('input.phone').attr('value', customer.mobileNumber).attr('readonly', true);
-
 
379
		if(customer.emailId!=null) {
-
 
380
			$('#email').attr('value', customer.emailId).attr('readonly', true);
-
 
381
		}
352
		$('#firstName').attr('value', customer.firstName);
382
		$('#firstName').attr('value', customer.firstName);
353
		$('#lastName').attr('value', customer.lastName);
383
		$('#lastName').attr('value', customer.lastName);
354
		$('#alternatePhone').attr('value', customer.mobileNumber);
384
		$('#alternatePhone').attr('value', customer.mobileNumber);
355
	    customerId = customer.customerId;
385
	    customerId = customer.customerId;
356
	    $('input.firstName').attr('value', customer.firstName).attr('readonly', true);
-
 
357
	    $('input.lastName').attr('value', customer.lastName).attr('readonly', true);
-
 
358
	    if(customer.emailId!=null) {
-
 
359
	    	$('#email').attr('value', customer.emailId).attr('readonly', true);
-
 
360
	    }
-
 
361
	    $("div.billinginfo").show();
386
	    $("div.billinginfo").show();
362
	    trs = [];
387
	    trs = [];
-
 
388
	    if(customer.addresses != null) {
363
	    for(address of customer.addresses) {
389
	    	for(address of customer.addresses) {
-
 
390
	    		if(typeof pendingPO !=undefined) {
-
 
391
	    			if(pendingPO.customerAddressId==address.id) {
-
 
392
	    				trs.push(getAddressTr(address));
-
 
393
	    			}
-
 
394
	    		} else {
364
	    	trs.push(getAddressTr(address));
395
	    			trs.push(getAddressTr(address));
-
 
396
	    		}
-
 
397
	    	}
365
	    }
398
	    }
366
	    $("#address-body").html(trs.join(""));
399
	    $("#address-body").html(trs.join(""));
-
 
400
	    
367
	});
401
	});
368
}
402
}
369
function getAddressTr(customAddress) {
403
function getAddressTr(address) {
370
	var tr = [];
404
	var tr = [];
371
	tr.push(`<tr><td>${address.name} ${address.lastName}</td>`);
405
	tr.push(`<tr><td>${address.name} ${address.lastName}</td>`);
372
	tr.push(`<td>${address.line1}, ${address.line2}</td>`);
406
	tr.push(`<td>${address.line1}, ${address.line2}</td>`);
373
	tr.push(`<td>${address.city}</td>`);
407
	tr.push(`<td>${address.city}</td>`);
374
	tr.push(`<td>${address.state}</td>`);
408
	tr.push(`<td>${address.state}</td>`);
375
	tr.push(`<td>${address.pinCode}</td>`);
409
	tr.push(`<td>${address.pinCode}</td>`);
376
	tr.push(`<td>${address.phoneNumber}</td>`);
410
	tr.push(`<td>${address.phoneNumber}</td>`);
377
	tr.push(`<td><a href="javascript:void();" data-addressid="${address.id}">Select address</a></td></tr>`);
411
	tr.push(`<td><a class="select-address" href="javascript:void(0);" data-addressid="${address.id}">Select address</a></td></tr>`);
378
	return tr.join("");
412
	return tr.join("");
379
}
413
}
380
414