· 7 years ago · Jan 04, 2019, 10:10 PM
1(index.php)
2
3<?php
4 require_once('auth.php');
5?>
6<?php
7include('db.php');
8?>
9
10<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
11<html xmlns="http://www.w3.org/1999/xhtml">
12<head>
13<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
14<title>POS</title>
15<script type="text/javascript" src="http://ajax.googleapis.com/
16ajax/libs/jquery/1.5/jquery.min.js"></script>
17<script type="text/javascript">
18$(document).ready(function()
19{
20$(".edit_tr").click(function()
21{
22var ID=$(this).attr('id');
23$("#first_"+ID).show();
24$("#last_"+ID).hide();
25$("#last_input_"+ID).show();
26}).change(function()
27{
28var ID=$(this).attr('id');
29var first=$("#first_input_"+ID).val();
30var last=$("#last_input_"+ID).val();
31var dataString = 'id='+ ID +'&price='+first+'&qty_sold='+last;
32$("#first_"+ID).html('<img src="load.gif" />');
33
34
35if(first.length && last.length>0)
36{
37$.ajax({
38type: "POST",
39url: "table_edit_ajax.php",
40data: dataString,
41cache: false,
42success: function(html)
43{
44
45$("#first_"+ID).html(first);
46$("#last_"+ID).html(last);
47}
48});
49}
50else
51{
52alert('Enter something.');
53}
54
55});
56
57$(".editbox").mouseup(function()
58{
59return false
60});
61
62$(document).mouseup(function()
63{
64$(".editbox").hide();
65$(".text").show();
66});
67
68});
69</script>
70<style>
71body
72{
73font-family:Arial, Helvetica, sans-serif;
74font-size:14px;
75padding:10px;
76}
77.editbox
78{
79display:none
80}
81td
82{
83padding:7px;
84border-left:1px solid #fff;
85border-bottom:1px solid #fff;
86}
87table{
88border-right:1px solid #fff;
89}
90.editbox
91{
92font-size:14px;
93width:29px;
94background-color:#ffffcc;
95
96border:solid 1px #000;
97padding:0 4px;
98}
99.edit_tr:hover
100{
101background:url(edit.png) right no-repeat #80C8E5;
102cursor:pointer;
103}
104.edit_tr
105{
106background: none repeat scroll 0 0 #D5EAF0;
107}
108th
109{
110font-weight:bold;
111text-align:left;
112padding:7px;
113border:1px solid #fff;
114border-right-width: 0px;
115}
116.head
117{
118background: none repeat scroll 0 0 #91C5D4;
119color:#00000;
120
121}
122
123</style>
124<link rel="stylesheet" href="reset.css" type="text/css" media="screen" />
125
126<link rel="stylesheet" href="tab.css" type="text/css" media="screen" />
127<link rel="stylesheet" type="text/css" href="tcal.css" />
128<script type="text/javascript" src="tcal.js"></script>
129<link href="tabs.css" rel="stylesheet" type="text/css" />
130<script type="text/javascript">
131
132var popupWindow=null;
133
134function child_open()
135{
136
137popupWindow =window.open('printform.php',"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=950, height=400,top=200,left=200");
138
139}
140</script>
141</head>
142
143<body bgcolor="#dedede">
144<h1>POS</h1>
145<ol id="toc">
146 <li><a href="clients.html"><span>Clients</span></a></li>
147 <li><a href="#inventory"><span>Inventory</span></a></li>
148 <li><a href="#addedit"><span>Add/Edit Product</span></a></li>
149 <li><a href="#cashrep"><span>Cashier's Daily Report</span></a></li>
150<?php if($_SESSION['SESS_AUTH'] == 'admin')
151 echo "
152 <li><a href="#reports"><span>Reports</span></a></li>";?>
153 <li><a href="index.php"><span>Logout</span></a></li>
154</ol>
155
156<div class="content" id="inventory">
157Click the table rows to enter the quantity sold<br><br>
158<table width="100%">
159<tr class="head">
160<th>Date</th>
161<th>Item</th>
162<th>Quantity Left</th>
163<th>Qty Sold </th>
164<th>Price</th>
165</tr>
166<?php
167$da=date("Y-m-d");
168
169$sql=mysql_query("select * from inventory");
170$i=1;
171while($row=mysql_fetch_array($sql))
172{
173$id=$row['id'];
174$date=$row['date'];
175$item=$row['item'];
176$qtyleft=$row['qtyleft'];
177$qty_sold=$row['qty_sold'];
178$price=$row['price'];
179$sales=$row['sales'];
180
181if($i%2)
182{
183?>
184<tr id="<?php echo $id; ?>" class="edit_tr">
185<?php } else { ?>
186<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
187<?php } ?>
188<td class="edit_td">
189<span class="text"><?php echo $da; ?></span>
190</td>
191<td>
192<span class="text"><?php echo $item; ?></span>
193</td>
194<td>
195<span class="text"><?php echo $qtyleft; ?></span>
196</td>
197<td>
198
199<span id="last_<?php echo $id; ?>" class="text">
200<?php
201$sqls=mysql_query("select qty from sales where date='$da' and product_id='$id'");
202while($rows=mysql_fetch_array($sqls))
203{
204echo $rows['qty'];
205}
206?>
207</span>
208<input type="text" value="<?php echo $rtrt; ?>" class="editbox" id="last_input_<?php echo $id; ?>" onblur="window.location.reload();" />
209</td>
210<td>
211<span id="first_<?php echo $id; ?>" class="text"><?php echo $price;?></span>
212<input type="text" value="<?php echo $price; ?>" class="editbox" id="first_input_<?php echo $id; ?>" />
213</td>
214<?php
215$sqls=mysql_query("select * from sales where date='$da' and product_id='$id'");
216while($rows=mysql_fetch_array($sqls))
217{
218$rtyrty=$rows['qty'];
219$rrrrr=$rtyrty*$price;
220}
221
222?>
223</tr>
224<?php
225$i++;
226}
227?>
228
229</table>
230<br />
231Your Total Sales For Today:
232 <b> Q<?php
233function formatMoney($number, $fractional=false) {
234 if ($fractional) {
235 $number = sprintf('%.2f', $number);
236 }
237 while (true) {
238 $replaced = preg_replace('/(-?d+)(ddd)/', '$1,$2', $number);
239 if ($replaced != $number) {
240 $number = $replaced;
241 } else {
242 break;
243 }
244 }
245 return $number;
246}
247
248$totq=mysql_query("select * from sales where date='$da'");
249while($rows=mysql_fetch_array($totq))
250{
251$rtyrty=$rows['qty'];
252$rtyrpr=$rows['sales'];
253$rrrrrt=$rtyrty*$rtyrpr;
254//echo $rrrrrt;
255}
256
257?></b><br /><br />
258<input name="" type="button" value="Print" onclick="javascript:child_open()" style="cursor:pointer;" />
259<br><br>
260<span class="content" id="alert">
261<?php
262 $CRITICAL=15;
263 $sql1=mysql_query("select * from inventory where qtyleft<='$CRITICAL'");
264 if($row1=mysql_fetch_array($sql1))
265 echo "Order More:<br>";
266 echo "<ul>";
267 $sql2=mysql_query("select * from inventory where qtyleft<='$CRITICAL'");
268 while($row2=mysql_fetch_array($sql2))
269 {
270 echo '<li>'.$row2['item'].'</li>';
271 }
272 ?>
273 </ul>
274</span>
275</div>
276<div class="content" id="cashrep">Needs Work
277</div>
278<div class="content" id="reports">
279 <form action="tableedit.php#reports" method="post">
280 From: <input name="from" type="text" class="tcal"/>
281 To: <input name="to" type="text" class="tcal"/>
282 <input name="" type="submit" value="Seach" />
283 </form><br />
284 Total Sales:
285 <?php
286 $a=$_POST['from'];
287 $b=$_POST['to'];
288 $result1 = mysql_query("SELECT sum(sales) FROM sales where date BETWEEN '$a' AND '$b'");
289 while($row = mysql_fetch_array($result1))
290 {
291 $rrr=$rrr+$row['sum(sales)'];
292 echo formatMoney($rrr, true);
293 }
294 ?>
295</div>
296<div class="content" id="addedit">
297<h2>Add New Product To Inventory</h2><br><br>
298<form action="saveproduct.php" method="post">
299 <div style="margin-left: 48px;">
300 Product name:<input name="proname" type="text" />
301 </div>
302 <br />
303 <div style="margin-left: 97px;">
304 Price: Q<input name="price" type="text" />
305 </div>
306 <br />
307 <div style="margin-left: 80px;">
308 Quantity:<input name="qty" type="text" />
309 </div>
310 <div style="margin-left: 127px; margin-top: 14px;"><input name="" type="submit" value="Add" /></div>
311</form>
312<br><br>
313<h2>Add Additional Product To Inventory</h2><br><br>
314<form action="updateproduct.php" method="post">
315 <div style="margin-left: 48px;">
316 Product name:<?php
317 $name= mysql_query("select * from inventory");
318
319 echo '<select name="ITEM" id="user" class="textfield1">';
320 while($res= mysql_fetch_assoc($name))
321 {
322 echo '<option value="'.$res['id'].'">';
323 echo $res['item'];
324 echo'</option>';
325 }
326 echo'</select>';
327 ?>
328 </div>
329 <br />
330 Number of Item To Add:<input name="itemnumber" type="text" /><br />
331 <div style="margin-left: 127px; margin-top: 14px;"><input name="" type="submit" value="Add" /></div>
332</form>
333<?php if($_SESSION['SESS_AUTH'] == 'admin') {
334 echo '
335<br><br>
336<h2>Edit Product Price</h2><br><br>
337<form action="updateprice.php" method="post">
338 <div style="margin-left: 48px;">
339 Product name:';
340 $name= mysql_query("select * from inventory");
341
342 echo '<select name="ITEM" id="user" class="textfield1">';
343 while($res= mysql_fetch_assoc($name))
344 {
345 echo '<option value="'.$res['id'].'">';
346 echo $res['item'];
347 echo'</option>';
348 }
349 echo'</select>';
350 echo '
351 </div>
352 <br />
353 <div style="margin-left: 97px;">Price:<input name="itemprice" type="text" /></div>
354 <div style="margin-left: 127px; margin-top: 14px;"><input name="" type="submit" value="Update" /></div>
355</form>';}?>
356</div>
357<script src="activatables.js" type="text/javascript"></script>
358<script type="text/javascript">
359 activatables('page', ['inventory', 'alert', 'reports', 'addedit', 'cashrep']);
360</script>
361</body>
362</html>
363======================================================================
364(table_edit_ajax.php)
365
366<?php
367include("db.php");
368if($_POST['id'])
369{
370$id=mysql_escape_String($_POST['id']);
371$qty_sold=mysql_escape_String($_POST['qty_sold']);
372$price=mysql_escape_String($_POST['price']);
373$da=date("Y-m-d");
374$sql=mysql_query("select * from inventory where id='$id'");
375while($row=mysql_fetch_array($sql))
376{
377$qtyleft=$row['qtyleft'];
378$price=$row['price'];
379}
380$ssss=$qtyleft-$qty_sold;
381$sale=$qty_sold*$price;
382$sales_sql=mysql_query("select * from sales where date='$da' and product_id='$id'");
383$count=mysql_num_rows($sales_sql);
384
385if($count==0)
386{
387mysql_query("INSERT INTO sales (product_id, qty, date, sales) VALUES ('$id','$qty_sold','$da','$sale')");
388}
389if($count!=0)
390{
391mysql_query("UPDATE sales set qty=qty+'$qty_sold',sales='$sale' where date='$da' and product_id='$id'");
392}
393
394$sql = "update inventory set qtyleft='$ssss',price='$price',sales=sales+'$sale',qty_sold=qty_sold+'$qty_sold' where id='$id'";
395mysql_query($sql);
396}
397?>
398
399===========================================================================
400(SQL table)
401
402 -- phpMyAdmin SQL Dump
403-- version 3.5.8.2
404-- http://www.phpmyadmin.net
405--
406-- Host: sql210.epizy.com
407-- Generation Time: Jan 04, 2019 at 04:51 PM
408-- Server version: 5.6.41-84.1
409-- PHP Version: 5.3.3
410
411SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
412SET time_zone = "+00:00";
413
414
415/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
416/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
417/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
418/*!40101 SET NAMES utf8 */;
419
420--
421-- Database: `epiz_23211543_liveedit`
422--
423
424-- --------------------------------------------------------
425
426--
427-- Table structure for table `inventory`
428--
429
430CREATE TABLE IF NOT EXISTS `inventory` (
431 `id` int(11) NOT NULL AUTO_INCREMENT,
432 `item` varchar(100) NOT NULL,
433 `qtyleft` int(11) NOT NULL,
434 `qty_sold` int(11) NOT NULL,
435 `price` int(11) NOT NULL,
436 `sales` int(11) NOT NULL,
437 PRIMARY KEY (`id`)
438) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
439
440--
441-- Dumping data for table `inventory`
442--
443
444INSERT INTO `inventory` (`id`, `item`, `qtyleft`, `qty_sold`, `price`, `sales`) VALUES
445(7, 'raptor', 6, 1, 7, 7);
446
447-- --------------------------------------------------------
448
449--
450-- Table structure for table `sales`
451--
452
453CREATE TABLE IF NOT EXISTS `sales` (
454 `id` int(11) NOT NULL AUTO_INCREMENT,
455 `product_id` int(11) NOT NULL,
456 `qty` int(11) NOT NULL,
457 `date` varchar(30) NOT NULL,
458 `sales` int(11) NOT NULL,
459 PRIMARY KEY (`id`)
460) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
461
462--
463-- Dumping data for table `sales`
464--
465
466INSERT INTO `sales` (`id`, `product_id`, `qty`, `date`, `sales`) VALUES
467(17, 7, 1, '2018-12-31', 7);
468
469-- --------------------------------------------------------
470
471--
472-- Table structure for table `user`
473--
474
475CREATE TABLE IF NOT EXISTS `user` (
476 `id` int(11) NOT NULL AUTO_INCREMENT,
477 `authorization` varchar(5) NOT NULL,
478 `username` varchar(100) NOT NULL,
479 `password` varchar(100) NOT NULL,
480 PRIMARY KEY (`id`)
481) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;
482
483--
484-- Dumping data for table `user`
485--
486
487INSERT INTO `user` (`id`, `authorization`, `username`, `password`) VALUES
488(1, 'admin', 'admin', '25181dd17ec0434c26c89ecc1d455980'),
489(2, 'user', 'bacu', 'd7216dec976c1beb88a5b60e749abf07');
490
491/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
492/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
493/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;