Domain Empire

[PHP] Inventory code with PHPwpos

Spaceship Spaceship
Watch
I am currenlty working with a custom model of PHPwpos to set up a cash register system connected to DB. The problem is that the ordered items are not substracted from the connected DB, so it doesnt keep track of the inventory.

The main code is posted here, if anything needed else please let me know (i'm fairly new with this)

*EDIT*

Also when a discount is entered, the substraced amount doesnt show. Only after the receipt is printed the total amount with discount is shown

PHP:
<?php
$sql = "select * from sales where id=" .$_GET['id'];
$result = $db->query($sql);
$sales_info = mysql_fetch_object($result);
$sql = "select * from customers where id=". $sales_info->customer_id;
$result = $db->query($sql);
$cust_info = mysql_fetch_object($result);
?>

<div id="sale_info">
<table>
<tr>
	<td>Reference:</td><td width="200"><?php echo $sales_info->id; ?></td>
	<td>Customer:</td><td><?php echo $cust_info->last_name . ", ". $cust_info->first_name; ?></td>
</tr><tr>
	<td>Date:</td><td><?php echo $sales_info->date; ?></td>
	<td valign="top">Address:</td><td><?php echo $cust_info->address; ?></td>
</tr><tr>
	<td>Sold by:</td><td><?php echo $sales_info->sold_by; ?></td>
	<td> </td><td><?php echo $cust_info->pcode . "  ". $cust_info->city. "  ". $cust_info->state; ?></td>
</tr><tr>
	<td>Payment:</td><td><?php echo $sales_info->paid_with; ?></td>
	<td> </td><td><?php echo $cust_info->country; ?></td>
</tr>
</table>
<hr>
<table width="100%" cellspacing="0">
<?php
$sql = "select item_name, quantity_purchased, item_total_cost from sales_items, items where sales_items.item_id=items.id and sale_id=" .$_GET['id'];
$result = $db->query($sql);
while($sales_items = mysql_fetch_row($result)){
?><tr><td width="40" align="left"><?php echo $sales_items[1]; ?></td><td align="left"><?php echo $sales_items[0]; ?></td><td width="50" align="right"><?php echo $sales_items[2]; ?></td></tr><?php
}
?>
</table>
</div>
<hr>
<div style="float:none;">
<table cellpadding="0" align="right">
<tr>
	<td width="200">Sub total:</td><td align="right"><?php echo sprintf("%01.2f",$sales_info->sale_sub_total); ?></td>
</tr>
<? if ($sales_info->discount_perc) { ?>
<tr>
	<td>Discount (<?php echo $sales_info->discount_perc; ?>%):</td><td align="right">-<?php echo sprintf("%01.2f",$sales_info->sale_sub_total*($sales_info->discount_perc/100)); ?></td>
</tr>
<? } ?>
<tr>
	<td>Tax:</td><td align="right"><?php echo sprintf("%01.2f",$sales_info->sale_total_cost-($sales_info->sale_sub_total*(1-($sales_info->discount_perc/100)))-$sales_info->ordercosts); ?></td>
</tr>
<tr>
	<td>Order costs:</td><td align="right"><?php echo sprintf("%01.2f",$sales_info->ordercosts); ?></td>
</tr>
<tr>
	<td id="total">Total:</td><td align="right"><b><?php echo sprintf("%01.2f",$sales_info->sale_total_cost); ?></b></td>
</tr>
</table>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back