Lid |
|
Ik ben op dit moment bezig met een custom model van PHPwpos om een kassa systeem op te zetten voor een winkel. De kassa is met dit systeem gelinkt aan een DB waar de voorraad wordt bijgehouden. Hoewel het systeem wel bijhoudt wat er verkocht is, is het probleem dat wanneer iemand iets gekocht en afgerekend heeft, de voorraad niet wordt bijgewerkt in de DB.
Ook wordt de korting niet weergegeven in de prijs wanneer er afgerekend wordt, pas nadat de bon is geprint staat het correcte bedrag weergeven.
Hieronder staat de code die als het goed is hier mee te maken heeft. Als er iets mist, laat het even weten, ik ben vrij nieuw met dit.
<?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>
<?php $sql = "select * from sales where id=" .$_GET['id']; $result = $db->query($sql); $sql = "select * from customers where id=". $sales_info->customer_id; $result = $db->query($sql); ?> <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); ?><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>
|