The Milk Shop System is developed using php. The project is built to manage sales and transactions. To make a new transaction, fields such as:items type , qty needs to be selected. If you like to learn point of sales systems step by step, this is the right place to learn from the beginning. In this tutorial useful for making a point of sales system for a small shops.
Paste the following code inside the index.php
<html>
<head>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
</head>
<body>
<nav class="navbar navbar-dark bg-danger">
<span class="navbar-brand mb-1 h1"><h1>MilkBar Inventory Management</h1></span>
</nav>
</br>
<div class="row">
<div class="col-sm-5">
<div class="container">
<div class="p-3 mb-2 bg-success text-white"><h2>Item</h2></div>
<div class="panel-body bg-danger" style="background-color:red; color: white">
<form id="tbl-project">
<div class="panel-body bg-warning style="color: white">
<table class="table table-bordered" style="color: black">
<tr>
<td>
<input type="checkbox" name="pos" value="Strawberry">
<label>Strawberry</label>
</td>
<td>
<input type="number" name="qty" id="qty" size="10px">
</td>
<td>
<select class="form-control" id="option" name="option" placeholder="option" required>
<option value="">Please Select</option>
<option value="1">ML</option>
<option value="2">L</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="pos" value="Chocolate">
<label>Chocolate </label>
</td>
<td>
<input type="number" name="qty" size="10px">
</td>
<td>
<select class="form-control" id="option" name="option" placeholder="option" required>
<option value="">Please Select</option>
<option value="1">ML</option>
<option value="2">L</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="pos" value="Vanilla">
<label> Vanilla</label>
</td>
<td>
<input type="number" name="qty" size="10px">
</td>
<td>
<select class="form-control" id="option" name="option" placeholder="option" required>
<option value="">Please Select</option>
<option value="1">ML</option>
<option value="2">L</option>
</select>
</td>
</tr>
</table>
<div>
<button type="button" class="btn btn-info" onclick="Add()" name="Ok" id="Ok"> OK
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="container">
<div class="list-group-item list-group-tem-action active" align="center"><h2>AddProducts</h2></div>
<table id="tbl-item" class="table table-dark table-bordered" cellspacing="0" width="100%" align="center">
<thead>
<tr>
<th>Delete</th>
<th>Item</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
</tr>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="col-sm-2" align="center">
<div class="list-group-item list-group-item-action active" align="center"><h2>Bill</h2></div>
<div>
<input type="text" style="color: yellow; background: black; font-size: 25px;" id="total" name="total" placeholder="Total" required>
</div>
</br>
<div>
<input type="button" class="btn btn-warning" value="Reset" name="reset" id="reset">
</div>
</div>
</div>
<script type="text/javascript">
var tot = 0;
var total = 0;
var price = 0;
function Add() {
$("input[name='pos']:checked").each(function() {
// Get the value
let check = $(this).val();
if (check == "Strawberry")
{
price = 300;
}
else if (check == "Chocolate")
{
price = 500;
}
else if (check == "Vanilla")
{
price = 100;
}
var calamount=0;
var qty = $(this).closest("tr").find('[name="qty"]').val() || 0;
var optionchange = $(this).closest("tr").find("select");
if (optionchange.val() == 2)
{
var calamount = (qty * price); // L
}
if (optionchange.val() == 1)
{
var calamount = parseFloat(qty / 1000 * price); // ML
}
var table1 =
"<tr>" +
"<td><button type='button' name='record' class='btn btn-warning' onclick='deleterow(this)'>Delete </td>" +
"<td>" + check + "</td>" +
"<td>" + price + "</td>" +
"<td>" + qty + "</td>" +
"<td>" + calamount.toFixed(2) + "</td>" +
"</tr>";
total += Number(calamount);
$('#total').val(total);
$("#tbl-item tbody").append(table1);
});
}
function deleterow(e) {
total_cost = parseInt($(e).parent().parent().find('td:last').text(), 10);
total -= total_cost;
$('#total').val(total);
$(e).parent().parent().remove();
}
$('#reset').click(function() {
location.reload();
});
</script>
</body>
</html>