-
Notifications
You must be signed in to change notification settings - Fork 3
/
sales.php
400 lines (368 loc) · 12.2 KB
/
sales.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="assets/img/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Sales Billing</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<?php include 'csslibrary.php';?>
<?php include 'jslibrary.php';?>
<style>
table.dataTable thead th { font-size: 15px; color: black;text-align: center;}
table.dataTable tbody tr { cursor:pointer;}
tr td { text-align: center; }
</style>
</head>
<body>
<div class="wrapper">
<?php include 'left-nav.php';?>
<div class="main-panel">
<?php include 'upper-nav.php';?>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="header">
<div class="row" style="margin:10px;">
<div class="col-md-9">
<h4 class="title">Sales Invoices</h4>
<p class="category">*All Sales history</p>
</div>
<div class="col-md-3" style="padding-left:37px;">
<input type="button" value="+New Sales Invoice" id="btnAddSales" >
</div>
</div>
</div>
<div class="content">
<div class="row" style="margin:20px;">
<div class="col-md-4">
<label for="From">From: (DD/MM/YYYY)</label>
<input type="text" class="form-control" placeholder="DD/MM/YYYY" id="fromDate">
</div>
<div class="col-md-4">
<label for="From">From: (DD/MM/YYYY)</label>
<input type="text" class="form-control" placeholder="DD/MM/YYYY" id="toDate">
</div>
<div class="col-md-4">
<br/>
<button type="button" id="btnApplyFilter" class="btn" style="border-color: #2e6da4 ;background-color: #337ab7;color: white;">Filter</button>
</div>
</div>
<div class="row" style="margin:20px;">
<table id="invoiceGrandDisplay" style="text-align:center;" class="table table-condensed table-hover" width="100%"></table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="addNewSalesInvoice" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Sale Invoice</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<label for="usr">Select a Customer</label>
<input id="customerName" placeholder="Type customer name" style="width:100%;text-align:left;" type="text"></input>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" id="btnCreateSaleInvoice">Create Invoice</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="addCustomerModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<div class="row">
<div class="col-sm-4">
<h4 class="modal-title">Add Customer</h4>
</div>
<div class="col-sm-6" style="text-align:center">
<button type="button" class="btn btn-default" id="btnCustSave">Save</button>
</div>
<div class="col-sm-2">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<label for="usr">Customer Name(*required)</label>
<input type="text" value="" class="form-control" id="custName">
</div>
</div>
<br/>
<div class="row">
<div class="col-sm-12">
<label for="usr">GST Number</label>
<input type="text" value="" class="form-control" id="custGST">
</div>
</div>
<br/>
<div class="row">
<div class="col-sm-6">
<label for="usr">City</label>
<input type="text" class="form-control" id="custCity">
</div>
<div class="col-sm-6">
<label for="usr">State</label>
<div class="dropdown" id="drpState">
<button class="btn btn-default dropdown-toggle" id="custDrpstate" style="width:250px" type="button" data-toggle="dropdown">Select State
<span class="caret"></span></button>
<ul class="dropdown-menu" style="width:250px;height: 200px;overflow:auto">
<li><a value="Tamil Nadu">Tamil Nadu</a></li>
<li><a value="West Bengal">West Bengal</a></li>
<li><a value="Orissa">Orissa</a></li>
<li><a value="Delhi">Delhi</a></li>
<li><a value="Karnataka">Karnataka</a></li>
<li><a value="ANDAMANANDNICOBARISLANDS">Andaman and Nicobar Islands</a></li>
<li><a value="Andhra Pradesh">Andhra Pradesh</a></li>
<li><a value="ARUNACHALPRADESH">Arunachal Pradesh</a></li>
<li><a value="Assam">Assam</a></li>
<li><a value="Bihar">Bihar</a></li>
<li><a value="Chandigarh">Chandigarh</a></li>
<li><a value="Chhattisgarh">Chhattisgarh</a></li>
<li><a value="Dadra Nagar Haveli">Dadra Nagar Haveli</a></li>
<li><a value="Daman and Diu">Daman and Diu</a></li>
<li><a value="Goa">Goa</a></li>
<li><a value="Gujarat">Gujarat</a></li>
<li><a value="Haryana">Haryana</a></li>
<li><a value="Himachal Pradesh">Himachal Pradesh</a></li>
<li><a value="Jammu and Kashmir">Jammu and Kashmir</a></li>
<li><a value="Jharkhand">Jharkhand</a></li>
<li><a value="Kerala">Kerala</a></li>
<li><a value="Lakshadweep">Lakshadweep</a></li>
<li><a value="Madhya Pradesh">Madhya Pradesh</a></li>
<li><a value="Maharashtra">Maharashtra</a></li>
<li><a value="Manipur">Manipur</a></li>
<li><a value="Meghalaya">Meghalaya</a></li>
<li><a value="Mizoram">Mizoram</a></li>
<li><a value="Pondicherry">Pondicherry</a></li>
<li><a value="Punjab">Punjab</a></li>
<li><a value="Rajasthan">Rajasthan</a></li>
<li><a value="Sikkim">Sikkim</a></li>
<li><a value="OTHERTERRITORY">OTHERTERRITORY</a></li>
</ul>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-sm-6">
<label for="usr">Contact person</label>
<input type="text" value="" class="form-control" id="custContactName">
</div>
<div class="col-sm-6">
<label for="usr">PAN</label>
<input type="text" value="" class="form-control" id="custPAN">
</div>
</div>
<br/>
<div class="row" style= "display:none">
<div class="col-sm-6">
<label for="usr">PAN</label>
<input type="text" value="" class="form-control" id="custMobileNumber">
</div>
<div class="col-sm-6">
<label for="usr">Pin code</label>
<input type="text" value="" class="form-control" id="custPin">
</div>
</div>
<br/>
<div class="row">
<div class="col-sm-12">
<label for="usr">Address</label>
<textarea style= "width:100%;height:80px;" id="custAddress" value="" placeholder="Address"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$( function() {
$("#fromDate").datepicker({ dateFormat: 'dd/mm/yy' });
$("#toDate").datepicker({ dateFormat: 'dd/mm/yy' });
});
$(document).ready(function(){
var availableTags = [];
initCustomerName();
initInvoiceTable("1");
function initCustomerName()
{
$.ajax({
url: 'webmethods.php',
type: 'POST',
data: {type: 7},
success: function (d) {
dataRET=JSON.parse(d);
var autocompleteOptions = dataRET[1];
$('#customerName').autocomplete({
source: autocompleteOptions,
response: function(event, ui){
ui.content.push({id:'New Customer', label:'New Customer', value:''});
},
minLength: 0,
autoFocus: true,
open: function(event) {},
close: function() {},
focus: function(event,ui) {
},
select: function (e, ui) {
if(ui.item.label.trim() == "New Customer")
{
$("#addCustomerModal").modal('show');
//tempRow=$(emptyColumn).find('td:nth-child(2) input');
}
}
});
$(".ui-autocomplete").css("z-index", "2147483647");
},
error: function (log) {
console.log(log);
}
});
}
/*$(document).on("click", "#ui-id-1 li", function(event) {
if($(this).text().trim() == "New Customer")
{
$("#addItemModal").modal('show');
}
})*/
$('#btnAddSales').on('click',function(){
$("#addNewSalesInvoice").modal('show');
$('#customerName').val('');
})
$("#btnCustSave").on('click',function(){
if($("#custName").val().length > 0)
{
saveCustomerinDB();
}
else
alert("Please add Vendor Name");
})
function saveCustomerinDB()
{
$.ajax({
url: 'webmethods.php',
type: 'POST',
data: {type: 1, vendorName: $("#custName").val(),custGST: $("#custGST").val(),custCity: $("#custCity").val(),drpState: $("#drpState button").text(),custContactName: $("#custContactName").val(),custMobileNumber: $("#custMobileNumber").val(), custPAN: $("#custPAN").val(),custPin: $("#custPin").val(),custAddress: $("#custAddress").val(), query_type: "-99" },
success: function (d) {
console.log(d);
if(d == "1")
{
$("#addCustomerModal").modal('hide');
alert("Customer Saved");
initCustomerName();
}
},
error: function (log) {
console.log(log);
}
});
}
$('#btnCreateSaleInvoice').on('click',function(){
if($('#customerName').val().length> 0)
{
$("#addNewSalesInvoice").modal('hide');
$.ajax({
url: 'webmethods.php',
type: 'POST',
data: {type: 8, customerName: $("#customerName").val()},
success: function (d) {
d=d.split(',');
if(d[0] == "1")
{
window.location.href = "/gst/salesinvoice.php?action=new&cust_id="+d[1]+"&name="+$('#customerName').val().trim()+"&invId="+d[2];
}
},
error: function (log) {
console.log(log);
}
});
}
else
alert("Select a customer")
})
$( function() {
$( "#itemBillDate" ).datepicker();
});
function initInvoiceTable(mode)
{
$.ajax({
url: 'webmethods.php',
type: 'POST',
data: {type: 13, mode: mode, fromDate: $('#fromDate').val().trim(), toDate: $('#toDate').val().trim() },
success: function (data1) {
var arr = JSON.parse(data1);
fillInvoiceTable(arr);
},
error: function (log) {
console.log(log.message);
}
});
}
function fillInvoiceTable(dataSet)
{
$('#invoiceGrandDisplay').DataTable({
data: dataSet,
dom: 'Bfrtip',
buttons: [
'pdf'
],
destroy: true,
"aoColumns": [
{ "sType": "date-uk","sTitle": "DATE" },
{"sTitle": "INVOICE NO"},
{"sTitle": "CUSTOMER"},
{"sTitle": "GSTIN"},
{"sTitle": "TAXABLE AMOUNT"},
{"sTitle": "TAX"},
{"sTitle": "TOTAL AMOUNT"},
{"sTitle": "TYPE"}
]
});
}
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-uk-pre": function ( a ) {
if(a != null)
{
var ukDatea = a.split('/');
return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
}
},
"date-uk-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"date-uk-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
$('#btnApplyFilter').on('click',function(){
initInvoiceTable("2");
})
});
</script>
</html>