-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_sale.php
89 lines (83 loc) · 3.45 KB
/
add_sale.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
<?php
$page_title = 'Add Sale';
require_once('includes/load.php');
// Checkin What level user has permission to view this page
page_require_level(3);
?>
<?php
if(isset($_POST['add_sale'])){
$req_fields = array('s_id','quantity','price','total', 'date' );
validate_fields($req_fields);
if(empty($errors)){
$p_id = $db->escape((int)$_POST['s_id']);
$s_qty = $db->escape((int)$_POST['quantity']);
$s_total = $db->escape($_POST['total']);
$date = $db->escape($_POST['date']);
$s_date = make_date();
$sql = "INSERT INTO sales (";
$sql .= " product_id,qty,price,date";
$sql .= ") VALUES (";
$sql .= "'{$p_id}','{$s_qty}','{$s_total}','{$s_date}'";
$sql .= ")";
if($db->query($sql)){
update_product_qty($s_qty,$p_id);
$session->msg('s',"Sale added. ");
redirect('add_sale.php', false);
} else {
$session->msg('d',' Sorry failed to add!');
redirect('add_sale.php', false);
}
} else {
$session->msg("d", $errors);
redirect('add_sale.php',false);
}
}
?>
<?php include_once('layouts/header.php'); ?>
<div class="row">
<div class="col-12 col-md-6 p-3 p-md-5">
<img class="img-fluid" src="uploads/cool.png"/>
</div>
<div class="col-md-6 p-3 p-md-5">
<?php echo display_msg($msg); ?>
<form method="post" action="ajax.php" autocomplete="off" id="sug-form">
<div class="form-group">
<div class="input-group">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-upc-scan" viewBox="0 0 16 16">
<path d="M1.5 1a.5.5 0 0 0-.5.5v3a.5.5 0 0 1-1 0v-3A1.5 1.5 0 0 1 1.5 0h3a.5.5 0 0 1 0 1h-3zM11 .5a.5.5 0 0 1 .5-.5h3A1.5 1.5 0 0 1 16 1.5v3a.5.5 0 0 1-1 0v-3a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 1-.5-.5zM.5 11a.5.5 0 0 1 .5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 1 0 1h-3A1.5 1.5 0 0 1 0 14.5v-3a.5.5 0 0 1 .5-.5zm15 0a.5.5 0 0 1 .5.5v3a1.5 1.5 0 0 1-1.5 1.5h-3a.5.5 0 0 1 0-1h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 1 .5-.5zM3 4.5a.5.5 0 0 1 1 0v7a.5.5 0 0 1-1 0v-7zm2 0a.5.5 0 0 1 1 0v7a.5.5 0 0 1-1 0v-7zm2 0a.5.5 0 0 1 1 0v7a.5.5 0 0 1-1 0v-7zm2 0a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-7zm3 0a.5.5 0 0 1 1 0v7a.5.5 0 0 1-1 0v-7z"/>
</svg>
</button>
</span>
<input type="text" id="sug_input" class="form-control" name="title" placeholder="Search product....">
</div>
<div id="result" class="list-group"></div>
</div>
</form>
<div class="panel panel-default">
<div class="panel-heading clearfix">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Sale Eidt</span>
</strong>
</div>
<div class="panel-body">
<form method="post" action="add_sale.php">
<table class="table">
<thead class="bg-primary text-white">
<th> Item </th>
<th> Price </th>
<th> Qty </th>
<th> Total </th>
<!-- <th> Date</th>
<th> Action</th> -->
</thead>
<tbody id="product_info"> </tbody>
</table>
</form>
</div>
</div>
</div>
</div>
<?php include_once('layouts/footer.php'); ?>