Subversion Repositories SmartDukaan

Rev

Rev 20911 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6467 amar.kumar 1
$(function() {
2
	$('#add-nonserialized-return').live('click', function(){
3
		$('<br/><label>ItemId : </label><input class = "return-itemId" name = "returnItemId" type = "textbox"/>'
4
				+'<label>Quantity : </label><input class = "return-qty" name = "returnQty" type = "textbox"/>').appendTo('#nonserialized-items-container');
5
	});
6
 
7
	$('#add-serialized-return').live('click', function(){
8
		$('<br/><label>IMEI Number : </label><input class = "imei-number" name = "returnImeiNumber" type = "textbox"/>').appendTo('#serialized-items-container')
9
	});
10
 
13600 manish.sha 11
	/*$('.settlePurchaseReturn').live('click', function(){
6467 amar.kumar 12
		purchaseReturnId = $(this).attr('id');
13
		$.ajax({
14
	        type : "GET",
15
	        url : "/inventory/purchase-return!markSettled?purchaseReturnId="+purchaseReturnId,
16
	        success : function(response) {
17
	            alert("Purchase Return Settled");
18
	            document.location.reload(true);
19
	        }
20
	    });
13600 manish.sha 21
	});*/
6467 amar.kumar 22
 
10864 manish.sha 23
	$('.detailPurchaseReturn').live('click', function(){
24
		purchaseReturnId = $(this).attr('id');
25
		$.ajax({
26
	        type : "GET",
27
	        url : "/inventory/purchase-return!getItemDetailsForPurchaseReturn?purchaseReturnId="+purchaseReturnId,
28
	        success : function(response) {
29
	        	$.colorbox({
30
					inline : true,
31
			        width : "500px",
32
			        height : "500px",
10885 manish.sha 33
			        opacity : "0.20",
10864 manish.sha 34
			        overlayClose :	true,
35
			        escKey :	true,
36
			        href : $(response),
37
			        onClosed : function() {
38
			            //TODO
39
			        }
40
				});
41
	        },
42
	        error : function(response) {
43
				alert("Error in fetching Purchase Return Items");
44
			}			
45
	    });
46
	});
47
 
13600 manish.sha 48
	$('.purchaseReturnSettlementDetails').live('click',function(){
49
		purchaseReturnId = $(this).attr('id');
50
		$.ajax({
51
	        type : "GET",
52
	        url : "/inventory/purchase-return!getPurchaseReturnSettlements?purchaseReturnId="+purchaseReturnId,
53
	        success : function(response) {
54
	        	$.colorbox({
55
					inline : true,
56
			        width : "600px",
57
			        height : "500px",
58
			        opacity : "0.20",
59
			        overlayClose :	true,
60
			        escKey :	true,
61
			        href : $(response),
62
			        onClosed : function() {
63
			            //TODO
64
			        }
65
				});
66
	        },
67
	        error : function(response) {
68
				alert("Error in fetching Purchase Return Items");
69
			}			
70
	    });
71
	});
17405 manish.sha 72
	/*
16411 manish.sha 73
	$("#prReasonType").change(function () {
74
		var prReasonType = $(this).val();
75
		if(prReasonType=='WRONG_GRN'){
76
			$('div#grnIdDiv').show();
77
		}else{
78
			$('div#grnIdDiv').hide();
79
		}
17405 manish.sha 80
	});*/
16411 manish.sha 81
 
13600 manish.sha 82
	$('.settlePurchaseReturnForm').hide();
83
    $('.settlePurchaseReturn').attr('disabled',false);
84
 
85
    $('.settledAmount').keypress(function(e) {
86
        var a = [];
87
        var k = e.which;
88
 
89
        for (i = 48; i < 58; i++){
90
        	a.push(i);
91
        }
92
 
93
        if (!(a.indexOf(k)>=0)){
94
            e.preventDefault();
95
    	}
96
    });
97
 
98
    $('.settlePurchaseReturn').live('click', function() {
99
        $(this).hide();
100
        $('.settlePurchaseReturn').attr('disabled',true);
101
        $(this).siblings('.settlePurchaseReturnForm').show();
102
    });
103
 
104
    $('.cancelSettlementButton').live('click', function() {
105
        $(this).parent().siblings('.settlePurchaseReturn').show();
106
        $('.settlePurchaseReturn').attr('disabled',false);
107
        $('.settledAmount').val('');
108
        $('.settlementType').val('CREDIT_NOTE');
109
        $('.documentNumber').val('');
110
        $(this).parent().hide();
111
    });
112
 
113
    $('.settledPR').live('click', function() {
114
    	var purchaseReturnId = $(this).attr('purchaseReturnId');
115
    	var settledAmount = $('.settledAmount_'+purchaseReturnId).val();
116
    	var settlementType = $('.settlementType_'+purchaseReturnId).val();
117
    	var documentNumber = $('.documentNumber_'+purchaseReturnId).val();
118
    	submitSettlePRForm(purchaseReturnId, settledAmount, settlementType, documentNumber);
119
        return false;
120
    });
121
 
122
	/*$('#prAcceptRejectLink').live('click', function() {
123
		$("div#prAcceptRejectDiv").show();
124
		$('#purchaseReturnId').val('');
125
		$.colorbox({
126
            inline : true,
127
            width : "400px",
128
            height : "200px",
129
            href : "div#prAcceptRejectDiv",
130
            onClosed : function() {
131
                $("div#prAcceptRejectDiv").hide();
132
            }
133
		});
134
	});*/
135
 
20906 amit.gupta 136
 
137
 
10864 manish.sha 138
	$('#create-purchase-return').live('submit', function() {
16411 manish.sha 139
		$('#campaignListUpdate1').val('-1');
20911 amit.gupta 140
		var data = new FormData(this);
141
		//var inputs = $(this).find('input', 'select');
142
		/*$.each(inputs, function (i, input) {
20909 amit.gupta 143
			if(input.files != null){
20906 amit.gupta 144
				data.append('file', input.files[0]);
145
			} else {
146
	        	data.append(input.name,input.value);
147
			}
20911 amit.gupta 148
	    });*/
20910 amit.gupta 149
		createPurchaseReturnJS(data);
10864 manish.sha 150
    	return false;
151
	});
152
 
6467 amar.kumar 153
	$(function() {
154
		purchaseReturn = $('#purchase-return-table').dataTable({
155
			"sPaginationType": "full_numbers",
156
            "aaSorting" : [ [ 1, 'desc' ] ],
157
            "bAutoWidth": true,
158
            "iDisplayLength" : 25,
159
            "sDom" : 'T<"clear">lfrtip',
160
            "oTableTools" : {
161
                "sSwfPath" : "swf/copy_cvs_xls_pdf.swf"
162
            },
163
        });
164
	});
10864 manish.sha 165
});
166
 
167
 
168
function createPurchaseReturnJS(params){
169
	$.ajax({
170
        type : 'POST',
171
        url : '/inventory/purchase-return!createPurchaseReturn',
172
        data      : params,
20914 amit.gupta 173
        enctype: 'multipart/form-data',
20906 amit.gupta 174
        cache: false,
175
        contentType: false,
176
        processData: false,
10864 manish.sha 177
        success : function(response) {
178
        	alert(response);
179
        	document.location.href = '/inventory/purchase-return' ;
180
        },
181
        error : function() {
182
        	alert('Some Error occurred at Server End');
183
        	document.location.href = '/inventory/purchase-return';
184
        }
185
    });
13600 manish.sha 186
}
187
 
188
function submitSettlePRForm(purchaseReturnId, settledAmount, settlementType, documentNumber){
189
	$.ajax({
190
		type : "GET",
191
        url : "/inventory/purchase-return!settlePurchaseReturn?purchaseReturnId="+purchaseReturnId+"&settledAmount="+settledAmount+"&settlementType="+settlementType+"&documentNumber="+documentNumber,
192
        success : function(response) {
193
        	alert(response);
194
            document.location.reload(true);
195
        },
196
        error : function() {
197
        	alert('Some Error occurred at Server End');
198
        	document.location.reload(true);
199
        }
200
	});
10864 manish.sha 201
}