-
Notifications
You must be signed in to change notification settings - Fork 47
/
update_sales.php
775 lines (607 loc) · 35.7 KB
/
update_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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
<?php
include_once("init.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>POSNIC - Update Supplier</title>
<!-- Stylesheets -->
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="js/date_pic/date_input.css">
<link rel="stylesheet" href="lib/auto/css/jquery.autocomplete.css">
<!-- Optimize for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- jQuery & JS files -->
<?php include_once("tpl/common_js.php"); ?>
<script src="js/date_pic/jquery.date_input.js"></script>
<script src="lib/auto/js/jquery.autocomplete.js "></script>
<script src="js/script.js"></script>
<script>
/*$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }
});*/
$(document).ready(function() {
// validate signup form on keyup and submit
$("#form1").validate({
rules: {
bill_no: {
required: true,
minlength: 3
},
stockid: {
required: true
},
grand_total: {
required: true
},
supplier: {
required: true,
}
},
messages: {
supplier: {
required: "Please Enter Supplier"
},
stockid: {
required: "Please Enter Stock ID"
},
grand_total: {
required: "Add Stock Items"
},
bill_no: {
required: "Please Enter Bill Number",
minlength: "Bill Number must consist of at least 3 characters"
}
}
});
});
$(function() {
$("#supplier").autocomplete("customer1.php", {
width: 160,
autoFill: true,
selectFirst: true
});
$("#item").autocomplete("stock.php", {
width: 160,
autoFill: true,
mustMatch: true,
selectFirst: true
});
$("#item").blur(function()
{
document.getElementById('total').value=document.getElementById('sell').value * document.getElementById('quty').value
});
$("#item").blur(function()
{
$.post('check_item_details.php', {stock_name1: $(this).val() },
function(data){
$("#sell").val(data.sell);
$("#stock").val(data.stock);
$('#guid').val(data.guid);
if(data.sell!=undefined)
$("#0").focus();
}, 'json');
});
$("#supplier").blur(function()
{
$.post('check_customer_details.php', {stock_name1: $(this).val() },
function(data){
$("#address").val(data.address);
$("#contact1").val(data.contact1);
if(data.address!=undefined)
$("#0").focus();
}, 'json');
});
$('#test1').jdPicker();
$('#test2').jdPicker();
var hauteur=0;
$('.code').each(function(){
if($(this).height()>hauteur) hauteur = $(this).height();
});
$('.code').each(function(){ $(this).height(hauteur); });
});
function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8 && unicode!=46 && unicode!=37 && unicode!=38 && unicode!=39 && unicode!=40){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57)
return false
}
}
function edit_stock_details(id) {
document.getElementById('display').style.display="block";
document.getElementById('item').value=document.getElementById(id+'st').value;
document.getElementById('quty').value=document.getElementById(id+'q').value;
document.getElementById('sell').value=document.getElementById(id+'s').value;
document.getElementById('stock').value=document.getElementById(id+'p').value;
document.getElementById('total').value=document.getElementById(id+'to').value;
document.getElementById('posnic_total').value=document.getElementById(id+'to').value;
document.getElementById('guid').value=id;
document.getElementById('edit_guid').value=id;
}
function clear_data() {
document.getElementById('display').style.display="none";
document.getElementById('item').value="";
document.getElementById('quty').value="";
document.getElementById('sell').value="";
document.getElementById('stock').value="";
document.getElementById('total').value="";
document.getElementById('posnic_total').value="";
document.getElementById('guid').value="";
document.getElementById('edit_guid').value="";
}
function add_values(){
if(unique_check()){
if(document.getElementById('edit_guid').value==""){
if(document.getElementById('item').value!="" && document.getElementById('quty').value!="" && document.getElementById('total').value!=""){
code=document.getElementById('item').value;
quty=document.getElementById('quty').value;
sell=document.getElementById('sell').value;
disc=document.getElementById('stock').value;
total=document.getElementById('total').value;
item=document.getElementById('guid').value;
main_total=document.getElementById('posnic_total').value;
$('<tr id='+item+'><td><input type=hidden value='+item+' id='+item+'id ><input type=text name="stock_name[]" id='+item+'st style="width: 150px" class="round my_with" ></td><td><input type=text name=quty[] readonly="readonly" value='+quty+' id='+item+'q class="round my_with" style="text-align:right;" ></td><td><input type=text name=sell[] readonly="readonly" value='+sell+' id='+item+'s class="round my_with" style="text-align:right;" ></td><td><input type=text name=stock[] readonly="readonly" value='+disc+' id='+item+'p class="round my_with" style="text-align:right;" ></td><td><input type=text name=jibi[] readonly="readonly" value='+total+' id='+item+'to class="round my_with" style="width: 120px;margin-left:20px;text-align:right;" ><input type=hidden name=total[] id='+item+'my_tot value='+main_total+'> </td><td><input type=button value="" id='+item+' style="width:30px;border:none;height:30px;background:url(images/edit_new.png)" class="round" onclick="edit_stock_details(this.id)" ></td><td><input type=button value="" id='+item+' style="width:30px;border:none;height:30px;background:url(images/close_new.png)" class="round" onclick= $(this).closest("tr").remove() ></td></tr>').fadeIn("slow").appendTo('#item_copy_final');
document.getElementById('quty').value="";
document.getElementById('sell').value="";
document.getElementById('stock').value="";
document.getElementById('total').value="";
document.getElementById('item').value="";
document.getElementById('guid').value="";
if(document.getElementById('grand_total').value==""){
document.getElementById('grand_total').value=main_total;
}else{
document.getElementById('grand_total').value=parseFloat(document.getElementById('grand_total').value)+parseFloat(main_total);
}
document.getElementById('main_grand_total').value='$ ' + parseFloat(document.getElementById('grand_total').value).toFixed(2);
document.getElementById(item+'st').value=code;
document.getElementById(item+'to').value=total;
}else{
alert('Please Select An Item');
}
}else{
id=document.getElementById('edit_guid').value;
document.getElementById(id+'st').value=document.getElementById('item').value;
document.getElementById(id+'q').value=document.getElementById('quty').value;
document.getElementById(id+'s').value=document.getElementById('sell').value;
document.getElementById(id+'p').value=document.getElementById('stock').value;
data1=parseFloat(document.getElementById('grand_total').value)+parseFloat(document.getElementById('posnic_total').value)-parseFloat(document.getElementById(id+'to').value);
document.getElementById('main_grand_total').value=data1;
document.getElementById('grand_total').value=data1;
document.getElementById(id+'to').value=document.getElementById('total').value;
console.log();
// document.getElementById('grand_total').value=parseFloat(document.getElementById('grand_total').value)+parseFloat(document.getElementById('total').value);
//alert(data1);
//alert(parseFloat(document.getElementById(id+'my_tot').value));
//alert(parseFloat(document.getElementById('posnic_total').value));
balance_amount();
document.getElementById(id+'my_tot').value=document.getElementById('posnic_total').value
document.getElementById('quty').value="";
document.getElementById('sell').value="";
document.getElementById('stock').value="";
document.getElementById('total').value="";
document.getElementById('item').value="";
document.getElementById('guid').value="";
document.getElementById('edit_guid').value="";
}
document.getElementById('display').style.display="none";
} discount_amount();
}
function unique_check(){
if(!document.getElementById(document.getElementById('guid').value) || document.getElementById('edit_guid').value==document.getElementById('guid').value){
return true;
}else{
alert("This Item is already added In This Purchase");
document.getElementById('item').focus();
id=document.getElementById('edit_guid').value;
document.getElementById('item').focus();
document.getElementById('item').value=document.getElementById(id+'st').value;
document.getElementById('quty').value=document.getElementById(id+'q').value;
document.getElementById('sell').value=document.getElementById(id+'s').value;
document.getElementById('stock').value=document.getElementById(id+'p').value;
document.getElementById('total').value=document.getElementById(id+'to').value;
document.getElementById('guid').value=id;
document.getElementById('edit_guid').value=id;
return false;
}
}
function total_amount(){
document.getElementById('total').value=document.getElementById('sell').value * document.getElementById('quty').value
document.getElementById('posnic_total').value=document.getElementById('total').value;
// document.getElementById('total').value = '$ ' + parseFloat(document.getElementById('total').value).toFixed(2);
balance_amount();
}
function balance_amount(){
if(document.getElementById('grand_total').value!="" && document.getElementById('payment').value!=""){
data=parseFloat(document.getElementById('grand_total').value);
document.getElementById('balance').value=data-parseFloat(document.getElementById('payment').value);
console.log();
if(parseFloat(document.getElementById('grand_total').value) >= parseFloat(document.getElementById('payment').value)){
document.getElementById('balance').value=parseFloat(document.getElementById('grand_total').value)-parseFloat(document.getElementById('payment').value);
}else{
if(document.getElementById('grand_total').value!=""){
document.getElementById('balance').value='000.00';
document.getElementById('payment').value=parseFloat(document.getElementById('grand_total').value);
}else{
document.getElementById('balance').value='000.00';
document.getElementById('payment').value="";
}
}
}else{
document.getElementById('balance').value="";
}
}
function quantity_chnage(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=13 && unicode!=9){
}
else{
add_values();
}
if (unicode!=27){
}
else{
document.getElementById("item").focus();
}
}
function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8 && unicode!=46 && unicode!=37 && unicode!=27 && unicode!=38 && unicode!=39 && unicode!=40 && unicode!=9){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57)
return false
}
}
function stock_size(){
//alert(document.getElementById('stock').value);
if(parseFloat(document.getElementById('quty').value) > parseFloat(document.getElementById('stock').value)){
document.getElementById('quty').value=document.getElementById('stock').value;
}
}
function discount_amount(){
if(document.getElementById('grand_total').value!=""){
document.getElementById('disacount_amount').value=parseFloat(document.getElementById('grand_total').value)*(parseFloat(document.getElementById('discount').value))/100;
}
if(document.getElementById('discount').value==""){
document.getElementById('disacount_amount').value="";
}
discont=parseFloat(document.getElementById('disacount_amount').value);
if(document.getElementById('disacount_amount').value==""){
discont=0;
}
document.getElementById('payable_amount').value=parseFloat(document.getElementById('grand_total').value)-discont;
if(parseFloat(document.getElementById('payment').value)>parseFloat(document.getElementById('payable_amount').value)){
document.getElementById('payment').value=parseFloat(document.getElementById('payable_amount').value);
}
}
function reduce_balance(id){
var minus=parseFloat(document.getElementById(id+"my_tot").value);
document.getElementById('grand_total').value=parseFloat(document.getElementById('grand_total').value)-minus;
document.getElementById('main_grand_total').value='$ ' + parseFloat(document.getElementById('grand_total').value).toFixed(2);
discount_amount();
//console.log(id);
}
function discount_type(){
if(document.getElementById('round').checked){
document.getElementById("discount").readOnly=true;
document.getElementById("disacount_amount").readOnly=false;
if(parseFloat(document.getElementById('grand_total'))!=""){
document.getElementById('disacount_amount').value="";
document.getElementById('discount').value="";
discount_amount();
}
}else{
document.getElementById("discount").readOnly=false;
document.getElementById("disacount_amount").readOnly=true;
}
}
function discount_as_amount(){
if(parseFloat(document.getElementById('disacount_amount').value) > parseFloat(document.getElementById('grand_total').value))
document.getElementById('disacount_amount').value="";
document.getElementById('payable_amount').value=parseFloat(document.getElementById('grand_total').value);
if(document.getElementById('grand_total').value!=""){
if(parseFloat(document.getElementById('disacount_amount').value) < parseFloat(document.getElementById('grand_total').value))
{ discont=parseFloat(document.getElementById('disacount_amount').value);
document.getElementById('payable_amount').value=parseFloat(document.getElementById('grand_total').value)-discont;
if(parseFloat(document.getElementById('payment').value)>parseFloat(document.getElementById('payable_amount').value)){
document.getElementById('payment').value=parseFloat(document.getElementById('payable_amount').value);
}
}else{
// document.getElementById('disacount_amount').value=parseFloat(document.getElementById('grand_total').value)-1;
}
}
}
</script>
</head>
<body>
<!-- TOP BAR -->
<?php include_once("tpl/top_bar.php"); ?>
<!-- end top-bar -->
<!-- HEADER -->
<div id="header-with-tabs">
<div class="page-full-width cf">
<ul id="tabs" class="fl">
<li><a href="dashboard.php" class="dashboard-tab">Dashboard</a></li>
<li><a href="view_sales.php" class="active-tab sales-tab">Sales</a></li>
<li><a href="view_customers.php" class=" customers-tab">Customers</a></li>
<li><a href="view_purchase.php" class="purchase-tab">Purchase</a></li>
<li><a href="view_supplier.php" class=" supplier-tab">Supplier</a></li>
<li><a href="view_product.php" class="stock-tab">Stocks / Products</a></li>
<li><a href="view_payments.php" class="payment-tab">Payments / Outstandings</a></li>
<li><a href="view_report.php" class="report-tab">Reports</a></li>
</ul> <!-- end tabs -->
<!-- Change this image to your own company's logo -->
<!-- The logo will automatically be resized to 30px height. -->
<a href="#" id="company-branding-small" class="fr"><img src="<?php if(isset($_SESSION['logo'])) { echo "upload/".$_SESSION['logo'];}else{ echo "upload/posnic.png"; } ?>" alt="Point of Sale" /></a>
</div> <!-- end full-width -->
</div> <!-- end header -->
<!-- MAIN CONTENT -->
<div id="content">
<div class="page-full-width cf">
<div class="side-menu fl">
<h3>Sales Management</h3>
<ul>
<li><a href="add_sales.php">Add Sales</a></li>
<li><a href="view_sales.php">View Sales</a></li>
</ul>
</div> <!-- end side-menu -->
<div class="side-content fr">
<div class="content-module">
<div class="content-module-heading cf">
<h3 class="fl">Update sales</h3>
<span class="fr expand-collapse-text">Click to collapse</span>
<span class="fr expand-collapse-text initial-expand">Click to expand</span>
</div> <!-- end content-module-heading -->
<div class="content-module-main cf">
<?php
if(isset($_POST['supplier']) and isset($_POST['stock_name']))
{
$billnumber=mysql_real_escape_string($_POST['bill_no']);
$autoid1=mysql_real_escape_string($_POST['id']);
$customer=mysql_real_escape_string($_POST['supplier']);
$address=mysql_real_escape_string($_POST['address']);
$contact=mysql_real_escape_string($_POST['contact']);
$count = $db->countOf("customer_details", "customer_name='$customer'");
if($count==0)
{
$db->query("insert into customer_details(customer_name,customer_address,customer_contact1) values('$customer','$address','$contact')");
}
$payment=mysql_real_escape_string($_POST['payment']);
$balance=mysql_real_escape_string($_POST['balance']);
$newvalue =$balance;
$oldvalue = $db->queryUniqueValue("SELECT balance FROM customer_details WHERE customer_name='$customer'");
$diff=$newvalue-$oldvalue;
$temp_balance = (int) $temp_balance + (int) $diff;
$db->execute("UPDATE customer_details SET balance=$temp_balance WHERE customer_name='$customer'");$selected_date=$_POST['due'];
$selected_date=strtotime( $selected_date );
$mysqldate = date( 'Y-m-d H:i:s', $selected_date );
$due=$mysqldate;
$mode=mysql_real_escape_string($_POST['mode']);
$newvalue =$balance;
$oldvalue = $db->queryUniqueValue("SELECT balance FROM customer_details WHERE customer_name='$customer'");
$diff=$newvalue-$oldvalue;
$temp_balance = (int) $temp_balance + (int) $diff;
$db->execute("UPDATE customer_details SET balance=$temp_balance WHERE customer_name='$customer'");
$selected_date=$_POST['due'];
$selected_date=strtotime( $selected_date );
$mysqldate = date( 'Y-m-d H:i:s', $selected_date );
$due=$mysqldate;
$mode=mysql_real_escape_string($_POST['mode']);
$description=mysql_real_escape_string($_POST['description']);
$namet=$_POST['stock_name'];
$quantityt=$_POST['quanitity'];
$ratet=$_POST['sell'];
$tax=$_POST['tax'];
$tax_did=$_POST['tax_dis'];
if($_POST['tax']==""){
$tax=00;
}
if($_POST['tax_dis']==""){
}
$totalt=$_POST['total'];
$payable=mysql_real_escape_string($_POST['subtotal']);
$discount=mysql_real_escape_string($_POST['discount']);
$dis_amount=mysql_real_escape_string($_POST['dis_amount']);
if($_POST['dis_amount']==""){
$dis_amount=00;
}
if($_POST['discount']==""){
$discount=00;
}
$subtotal=mysql_real_escape_string($_POST['payable']);
$username=$_SESSION['username'];
$i=0;
$j=1;
foreach($namet as $name1)
{
$autoid=$_POST['s_id'][$i];
$quantity=$_POST['quantity'][$i];
$rate=$_POST['sell'][$i];
$total=$_POST['total'][$i];
$selected_date=$_POST['date'];
$selected_date=strtotime( $selected_date );
$mysqldate = date( 'Y-m-d H:i:s', $selected_date );
$username = $_SESSION['username'];
$count = $db->queryUniqueValue("SELECT count(*) FROM stock_avail WHERE name='$name1' and quantity >=$quantity");
if($count == 1)
{
$old_quantity= $db->queryUniqueValue("SELECT quantity FROM stock_sales WHERE id='$autoid' and count1=$i");
$db->query("update stock_sales set tax=$tax,tax_dis='$tax_did', grand_total=$payable,discount=$discount,dis_amount=$dis_amount, stock_name='$name1',selling_price=$rate,quantity=$quantity,amount=$total,date='$mysqldate',username='$username',customer_id='$customer',subtotal=$subtotal,payment=$payment,balance=$balance,due='$due',mode='$mode',description='$description',billnumber='$billnumber' where id=$autoid");
$quantity_diff=$quantity-$old_quantity;
$quantity=$quantity+$quantity_diff;
$amount = $db->queryUniqueValue("SELECT quantity FROM stock_avail WHERE name='$name1'");
$amount1 = $amount - $quantity;
$db->query("update stock_entries set stock_id='$autoid',stock_name='$name1',quantity=$quantity,opening_stock=$amount,closing_stock=$amount1,date='$mysqldate',username='$username',type='sales',salesid='$billnumber',total=$total,selling_price=$rate,billnumber='$billnumber' where salesid='$autoid' and count1=$j");
//echo "<br><font color=green size=+1 >New Sales Added ! Transaction ID [ $autoid ]</font>" ;
//echo "<br><font color=green size=+1> Current Stock Availability is [ $amount1 ]</font>" ;
$j++;
}
else
{
echo "<br><font color=green size=+1 >There is no enough stock deliver for $name1! Please add stock !</font>" ;
}
$i++;
}
$trans_id= trim($_POST['stockid']);
echo "<div style='background-color:yellow;'><br><font color=green size=+1 >Sales Updated ! Transaction ID [ $autoid ]</font></div> ";
echo "<script>window.open('add_sales_print.php?sid=$trans_id','myNewWinsr','width=620,height=800,toolbar=0,menubar=no,status=no,resizable=yes,location=no,directories=no');</script>";
}
//echo "<div style='background-color:yellow;'><br><font color=green size=+1 >Sales Updated ! Transaction ID [ $autoid ]</font></div> ";
//echo "<script>window.open('add_sales_print.php?sid=$autoid','myNewWinsr','width=620,height=800,toolbar=0,menubar=no,status=no,resizable=yes,location=no,directories=no');</script>";
?>
<?php
if(isset($_GET['sid']))
$id=$_GET['sid'];
$line = $db->queryUniqueObject("SELECT * FROM stock_sales WHERE id='$id'");
?>
<form name="form1" method="post" id="form1" action="">
<input type="hidden" id="posnic_total" >
<input type="hidden" name="id" value="<?php echo $id ?>" >
<table class="form" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
$max = $db->maxOfAll("id","stock_sales");
$max=$max+1;
$autoid="PR".$max."";
?>
<td>Stock ID:</td>
<td><input name="stockid" type="text" id="stockid" readonly="readonly" maxlength="200" class="round default-width-input" style="width:130px " value="<?php echo $line->transactionid ; ?>" /></td>
<td>Date:</td>
<td><input name="date" id="test1" placeholder="" value="<?php echo $line->date ; ?> " type="text" id="name" maxlength="200" class="round default-width-input" /></td>
<td><span class="man">*</span>Bill No:</td>
<td><input name="bill_no" placeholder="ENTER BILL NO" type="text" id="bill_no" maxlength="200" value="<?php echo $line->billnumber ; ?> " class="round default-width-input" style="width:120px " /></td>
</tr>
<tr>
<td><span class="man">*</span>Supplier:</td>
<td><input name="supplier" placeholder="ENTER SUPPLIER" type="text" id="supplier" value="<?php echo $line->customer_id ; ?> " maxlength="200" class="round default-width-input" style="width:130px " /></td>
<td>Address:</td>
<td><input name="address" placeholder="ENTER ADDRESS" type="text" value="<?php $quantity = $db->queryUniqueValue("SELECT customer_address FROM customer_details WHERE customer_name='".$line->customer_id."'"); echo $quantity; ?>" id="address" maxlength="200" class="round default-width-input" /></td>
<td>contact:</td>
<td><input name="contact" placeholder="ENTER CONTACT" type="text" value="<?php $quantity = $db->queryUniqueValue("SELECT customer_contact1 FROM customer_details WHERE customer_name='".$line->customer_id."'"); echo $quantity; ?>" id="contact1" maxlength="200" class="round default-width-input" onkeypress="return numbersonly(event)" style="width:120px " /></td>
</tr>
</table>
<input type="hidden" id="guid">
<input type="hidden" id="edit_guid">
<table id="hideen_display">
<tr >
<td>Item:</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>Quantity:</td>
<td>Selling:</td>
<td>Available Stock:</td>
<td>Total</td>
<td> </td>
<td> </td>
<td> </td><td> </td><td> </td><td> </td><td> </td><td> </td>
</tr>
</table>
<table class="form" id="display" style="display:none">
<tr >
<td><input name="" type="text" id="item" maxlength="200" class="round my_with " style="width: 150px" value="<?php echo $supplier; ?>" /></td>
<td><input name="" type="text" id="quty" maxlength="200" class="round my_with" onKeyPress="quantity_chnage(event);return numbersonly(event)" onkeyup="stock_size();total_amount();unique_check();" value="<?php echo $category; ?>" /></td>
<td><input name="" type="text" id="sell" readonly="readonly" maxlength="200" class="round my_with" value="<?php echo $category; ?>" /></td>
<td><input name="" type="text" id="stock" readonly="readonly" maxlength="200" class="round my_with" value="<?php echo $category; ?>" /></td>
<td><input name="" type="text" id="total" maxlength="200" class="round default-width-input " style="width:120px; margin-left: 20px" value="<?php echo $category; ?>" /></td>
<td><input type="button" onclick="add_values()" onkeyup=" balance_amount();" id="add_new_code" style="margin-left:20px; width:30px;height:30px;border:none;background:url(images/save.png)" class="round"> </td>
<td> <input type="button" value="" id="cancel" onclick="clear_data()" style="width:30px;float: right; border:none;height:30px;background:url(images/close_new.png)">
</td>
</tr>
</table>
<input type="hidden" id="guid">
<input type="hidden" id="edit_guid">
<div style="overflow:auto ;max-height:300px; ">
<table class="form" id="item_copy_final">
<?php
$sid=$line->transactionid ;
$max = $db->maxOf("count1", "stock_sales", "transactionid ='$sid'");
for($i=1; $i<=$max; $i++)
{
$line1 = $db->queryUniqueObject("SELECT * FROM stock_sales WHERE transactionid ='$sid' and count1=$i");
$item= $db->queryUniqueValue("SELECT transactionid FROM stock_sales WHERE stock_name='".$line1->stock_name."'");
?>
<tr>
<td><input name="stock_name[]" type="text" id="<?php echo $item."st"?>" maxlength="20" style="width: 150px" readonly="readonly" class="round "
value="<?php echo $line1->stock_name ; ?>" /></td>
<td><input name="quantity[]" type="text" id="<?php echo $item."q"?>" maxlength="20" class="round my_with"
value="<?php echo $line1->quantity ; ?>" readonly="readonly" onkeypress="return numbersonly(event)" /></td>
<td><input type="hidden" name="s_id[]" value="<?php echo $line1->id; ?>"> <input name="sell[]" type="text" id="<?php echo $item."s"?>" maxlength="20" readonly="readonly" class="round my_with"
value="<?php echo $line1->selling_price; ?>" onkeypress="return numbersonly(event)" /></td>
<td><input name="stock[]" type="text" id="<?php echo $item."p"?>" readonly="readonly" maxlength="200" class="round my_with" value="<?php $quantity = $db->queryUniqueValue("SELECT quantity FROM stock_avail WHERE name='".$line1->stock_name."'"); echo $quantity; ?>" /></td>
<td><input name="total[]" type="text" id="<?php echo $item."to"?>" readonly="readonly" maxlength="20" style="margin-left:20px;width: 120px" class="round "
value="<?php echo $line1->amount ; ?>" /></td>
<td><input type="hidden" id="<?php echo $item."my_tot"?>" maxlength="20" style="margin-left:20px;width: 120px" class="round "
value="<?php echo $line1->amount ; ?>" /></td>
<td><input type="hidden" id="<?php echo $item;?>"><input type="hidden" name="gu_id[]" value="<?php echo $line1->id ?>"></td>
<td><input type=button value="" id="<?php echo $item;?>" style="width:30px;border:none;height:30px;background:url(images/edit_new.png)" class="round" onclick="edit_stock_details(this.id)" ></td>
</tr>
<?php }?>
</table>
</div>
<table class="form">
<tr>
<td> </td> <td> </td>
<td><input type="checkbox" id="round" onclick="discount_type()" >Discount As Amount</td> </tr>
<tr>
<td> </td>
<td>Discount %<input type="text" maxlength="3" value="<?php echo $line->discount ; ?>" class="round" onkeyup=" discount_amount(); " onkeypress="return numbersonly(event);" name="discount" id="discount" >
</td>
<td>Discount Amount:<input type="text" readonly="readonly" value="<?php echo $line->dis_amount ; ?>" onkeypress="return numbersonly(event);" onkeyup=" discount_as_amount(); " class="round" id="disacount_amount" name="dis_amount" >
</td>
<td> </td><td> </td>
<td>Grand Total:<input type="hidden" readonly="readonly" value="<?php echo $line->grand_total ; ?>" id="grand_total" name="subtotal" >
<input type="text" id="main_grand_total" readonly="readonly" value="<?php echo $line->grand_total ; ?>" class="round default-width-input" style="text-align:right;width: 120px" >
</td>
<td>Description</td>
<td><textarea name="description"><?php echo $line->description ; ?></textarea></td>
</tr>
<tr> <td> </td>
<td>Payment:<input type="text" class="round" value="<?php echo $line->payment ; ?>" onkeyup=" balance_amount(); return numbersonly(event);" name="payment" id="payment" >
</td>
<td>Balance:<input type="text" class="round" value="<?php echo $line->balance ; ?>" id="balance" name="balance" >
</td>
<td> </td><td> </td>
<td>Payable Amount:<input type="hidden" readonly="readonly" id="grand_total" >
<input type="text" id="payable_amount" value="<?php echo $line->subtotal ; ?>" readonly="readonly" name="payable" class="round default-width-input" style="text-align:right;width: 120px" >
</td>
</tr> </table>
<table>
<tr> <td>Mode </td><td>
<select name="mode">
<option value="cheque">Cheque</option>
<option value="cheque">Cash</option>
<option value="cheque">Other</option>
</select>
</td>
<td>
Due Date:<input type="text" name="due" id="test2" value="<?php echo date('d-m-Y');?>" class="round">
</td>
<td> Tax:<input type="text" name="tax" value="<?php echo $line->tax ?>" onkeypress="return numbersonly(event);"></td>
<td>Tax Description:<input type="text" <?php echo $line->tax_dis ?> name="tax_dis"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table class="form">
<tr>
<td>
<input class="button round blue image-right ic-add text-upper" type="submit" name="Submit" value="Add">
</td><td> (Control + S)
<input class="button round red text-upper" type="reset" name="Reset" value="Reset"> </td>
<td> </td> <td> </td>
</tr>
</table>
</form>
</div> <!-- end content-module-main -->
</div> <!-- end content-module -->
</div> <!-- end full-width -->
</div> <!-- end content -->
<!-- FOOTER -->
<div id="footer">
<p>Any Queries email to <a href="mailto:[email protected]?subject=Stock%20Management%20System">[email protected]</a>.</p>
</div> <!-- end footer -->
</body>
</html>