Subversion Repositories SmartDukaan

Rev

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

Rev 23820 Rev 23873
Line 75... Line 75...
75
			});
75
			});
76
            return false; // required to block normal submit since you used ajax
76
            return false; // required to block normal submit since you used ajax
77
         }
77
         }
78
	});
78
	});
79
    
79
    
80
	$("input.unitPrice").blur(function() {
80
	$("input.unitPrice").change(function() {
81
		console.log("unitPrice blur called");
81
		console.log("unitPrice blur called");
82
		var $element = $(this);
82
		var $element = $(this);
83
		var unitPrice = parseFloat($element.val());
83
		var unitPrice = parseFloat($element.val());
84
		if(!isNaN(unitPrice)) {
84
		if(!isNaN(unitPrice)) {
-
 
85
			var itemType = parseFloat($(this).closest('tr').find('.serialNumber').attr("itemType"));
85
			var mopPrice = parseFloat($(this).attr('mopPrice'));
86
			var mopPrice = parseFloat($(this).attr('mopPrice'));
86
			var dp = parseFloat($(this).attr('dp'));
87
			var dp = parseFloat($(this).attr('dp'));
87
			if(!accessoriesDeals && unitPrice < mopPrice){
88
			if(!accessoriesDeals && unitPrice < mopPrice){
88
				alert("Selling Price must be greater than equal to MOP")
89
				alert("Selling Price must be greater than equal to MOP");
89
				$element.addClass("border-highlight");
90
				$element.addClass("border-highlight");
90
			}else if(unitPrice < dp){
91
			}else if(itemType=='SERIALIZED' && unitPrice < mop){
91
				alert("Selling Price must be greater than equal to Purchase Price")
92
				alert("Selling Price must be greater than equal to MOP");
-
 
93
				$element.addClass("border-highlight");
-
 
94
			}else if(itemType=='NON_SERIALIZED' && unitPrice < dp){
-
 
95
				alert("Selling Price must be greater than equal to DP");
92
				$element.addClass("border-highlight");
96
				$element.addClass("border-highlight");
93
			}else{
97
			}else{
94
				$element.removeClass("border-highlight")
98
				$element.removeClass("border-highlight")
95
				if(unitPrice == mopPrice){
99
				if(unitPrice == mopPrice){
96
					$("input.discountAmount").removeAttr("readonly");
100
					$("input.discountAmount").removeAttr("readonly");
Line 297... Line 301...
297
			}
301
			}
298
		});
302
		});
299
		
303
		
300
		var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty, 'prebookingOrder':prebookingOrder};
304
		var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty, 'prebookingOrder':prebookingOrder};
301
		tmpObj.discountAmount = discountAmount;
305
		tmpObj.discountAmount = discountAmount;
302
		/*tmpObj['serialNumberDetails'] = [];
-
 
303
		var found = false;
-
 
304
		for(var i = 0; i < priceQtyArray.length; i++){			
-
 
305
			if (priceQtyArray[i]["itemId"] == itemId){
-
 
306
				found = true;
-
 
307
				break;
-
 
308
			}
-
 
309
		}
306
 
310
		if(!found){
-
 
311
			priceQtyArray.push(tmpObj);
-
 
312
		}else{
-
 
313
			for(var i = 0; i < priceQtyArray.length; i++){			
-
 
314
				if (priceQtyArray[i]["itemId"] == itemId){
-
 
315
					priceQtyArray[i]["quantity"] = priceQtyArray[i]["quantity"] + 1;
-
 
316
					break;
-
 
317
				}
-
 
318
			}
-
 
319
		}
-
 
320
		var serialNumberDetails = getSerialNumbersFromOrder($el);
-
 
321
		if(serialNumberDetails != null){
-
 
322
			for(var i = 0; i < priceQtyArray.length; i++){			
-
 
323
				if (priceQtyArray[i]["itemId"] == itemId){
-
 
324
					priceQtyArray[i]["serialNumberDetails"].push(serialNumberDetails);
-
 
325
					break;
-
 
326
				}
-
 
327
			}
-
 
328
		}
-
 
329
		});*/
-
 
330
			
-
 
331
		if (orderObj['fofoOrderItems'][itemId] === undefined){
307
		if (orderObj['fofoOrderItems'][itemId] === undefined){
332
			tmpObj['serialNumberDetails'] =[];
308
			tmpObj['serialNumberDetails'] =[];
333
		}else{
309
		}else{
334
			//tmpObj['serialNumbers'] = orderObj['fofoLineItems'][itemId];
310
			//tmpObj['serialNumbers'] = orderObj['fofoLineItems'][itemId];
335
			tmpObj['serialNumberDetails'] = [];
311
			tmpObj['serialNumberDetails'] = [];