conn,$cfg_theme,$cfg_currency_symbol,$lang); $today = date("Y-m-d"); if(cfg_mustOpen && !$sec->isOpen()){ header("location: ../books/openshop.php"); exit(); } if(isset($_POST['customer'])) { if($cfg_numberForBarcode=="Row ID") { if($dbf->isValidCustomer($_POST['customer'])) { $_SESSION['current_sale_customer_id']=$_POST['customer']; } } else//try account_number { $id=$dbf->fieldToid($cfg_tableprefix.'customers','account_number',$_POST['customer']); if($dbf->isValidCustomer($id)) { $_SESSION['current_sale_customer_id']=$id; } else { echo "$lang->customerWithID/$lang->accountNumber ".$_POST['customer'].', '."$lang->isNotValid"; } } } ?> PHP Point Of Sale sale_bg; $items_table="$cfg_tableprefix".'items'; if(!$sec->isLoggedIn()) { header ("location: ../login.php"); exit(); } $display->displayTitle("$lang->newSale"); if(empty($_SESSION['current_sale_customer_id'])) { $customers_table="$cfg_tableprefix".'customers'; if(isset($_POST['customer_search']) and $_POST['customer_search']!='') { $search=$_POST['customer_search']; $_SESSION['current_customer_search']=$search; $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table WHERE last_name like \"%$search%\" or first_name like \"%$search%\" or id =\"$search\" ORDER by last_name",$dbf->conn); } elseif(isset($_SESSION['current_customer_search'])) { $search=$_SESSION['current_customer_search']; $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table WHERE last_name like \"%$search%\" or first_name like \"%$search%\" or id =\"$search\" ORDER by last_name",$dbf->conn); } elseif($dbf->getNumRows($customers_table) >200) { $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table ORDER by last_name LIMIT 0,200",$dbf->conn); } else { $customer_result=mysql_query("SELECT first_name,last_name,account_number,id FROM $customers_table ORDER by last_name",$dbf->conn); } $customer_title=isset($_SESSION['current_customer_search']) ? "$lang->selectCustomer: ":"$lang->selectCustomer: "; echo "

"; echo ""; } if(isset($_SESSION['current_sale_customer_id'])) { if(isset($_POST['item'])) { $item=$_POST['item']; $discount='0%'; if($cfg_numberForBarcode=="Account/Item Number") { $item=$dbf->fieldToid($items_table,'item_number',$_POST['item']); } if($dbf->isValidItem($item)) { if($dbf->isItemOnDiscount($item)) { $discount=$dbf->getPercentDiscount($item).'%'; $itemPrice=$dbf->getDiscountedPrice($item); } else { $itemPrice=$dbf->idToField($items_table,'unit_price',$item); } $itemTax=$dbf->idToField($items_table,'tax_percent',$item); $_SESSION['items_in_sale'][]=$item.' '.$itemPrice.' '.$itemTax.' '.'1'.' '.$discount; } else { echo "$lang->itemWithID/$lang->itemNumber ".$_POST['item'].', '."$lang->isNotValid"; } } if(isset($_SESSION['items_in_sale'])) { $num_items=count($_SESSION['items_in_sale']); } else { $num_items=0; } $temp_item_name=''; $temp_item_id=''; $temp_quantity=''; $temp_price=''; $finalSubTotal=0; $finalTax=0; $finalTotal=0; $totalItemsPurchased=0; $item_info=array(); $customers_table="$cfg_tableprefix".'customers'; $order_customer_first_name=$dbf->idToField($customers_table,'first_name',$_SESSION['current_sale_customer_id']); $order_customer_last_name=$dbf->idToField($customers_table,'last_name',$_SESSION['current_sale_customer_id']); $order_customer_name=$order_customer_first_name.' '.$order_customer_last_name; echo "
[$lang->clearSale]
"; $items_table="$cfg_tableprefix".'items'; $brands_table="$cfg_tableprefix".'brands'; if(isset($_POST['item_search']) and $_POST['item_search']!='') { $search=$_POST['item_search']; $_SESSION['current_item_search']=$search; $item_result=mysql_query("SELECT item_name,unit_price,tax_percent,brand_id,item_number,quantity,id FROM $items_table WHERE item_name like \"%$search%\" or item_number= \"$search\" or id =\"$search\" ORDER by item_name",$dbf->conn); } elseif(isset($_SESSION['current_item_search'])) { $search=$_SESSION['current_item_search']; $item_result=mysql_query("SELECT item_name,unit_price,tax_percent,brand_id,item_number,quantity,id FROM $items_table WHERE item_name like \"%$search%\" or item_number= \"$search\" or id =\"$search\" ORDER by item_name",$dbf->conn); } elseif($dbf->getNumRows($items_table) >200) { $item_result=mysql_query("SELECT item_name,unit_price,tax_percent,brand_id,item_number,quantity,id FROM $items_table ORDER by item_name LIMIT 0,200",$dbf->conn); } else { $item_result=mysql_query("SELECT item_name,unit_price,tax_percent,brand_id,item_number,quantity,id FROM $items_table ORDER by item_name",$dbf->conn); } $item_title=isset($_SESSION['current_item_search']) ? "$lang->selectItem: ":"$lang->selectItem: "; echo "
$lang->findCustomer: [$lang->clearSearch]
$customer_title"; echo "
($lang->scanInCustomer)
"; echo"$lang->customerID / $lang->accountNumber:
"; echo "
$lang->orderFor: $order_customer_name

$lang->findItem: [$lang->clearSearch]
$item_title
($lang->scanInItem)
$lang->itemID / $lang->itemNumber:
"; echo "

$lang->shoppingCart

"; echo ""; for($k=0;$k<$num_items;$k++) { $item_info=explode(' ',$_SESSION['items_in_sale'][$k]); $temp_item_id=$item_info[0]; $temp_item_name=$dbf->idToField($items_table,'item_name',$temp_item_id); $temp_price=$item_info[1]; $temp_tax=$item_info[2]; $temp_quantity=$item_info[3]; $temp_discount=$item_info[4]; $subTotal=$temp_price*$temp_quantity; $tax=$subTotal*($temp_tax/100); $rowTotal=$subTotal+$tax; $rowTotal=number_format($rowTotal,2,'.', ''); $finalSubTotal+=$subTotal; $finalTax+=$tax; $finalTotal+=$rowTotal; $totalItemsPurchased+=$temp_quantity; echo ""; } $finalSubTotal=number_format($finalSubTotal,2,'.', ''); $finalTax=number_format($finalTax,2,'.', ''); $finalTotal=number_format($finalTotal,2,'.', ''); echo '
$lang->remove $lang->itemName $lang->unitPrice $lang->tax % $lang->quantity $lang->extendedPrice $lang->update $lang->percentOff
[$lang->delete] $temp_item_name $cfg_currency_symbol$rowTotal $temp_discount $lang->percentOff
'; echo "
"; if(isset($_GET['global_sale_discount'])) { $discount=$_GET['global_sale_discount']; echo""; } echo""; echo'
$lang->saleSubTotal: $cfg_currency_symbol$finalSubTotal
$lang->tax: $cfg_currency_symbol$finalTax
$discount% $lang->percentOff
$lang->saleTotalCost: $cfg_currency_symbol$finalTotal
'; echo "

$lang->globalSaleDiscount

"; echo "
$lang->paidWith: $lang->amtTendered:
$lang->saleComment:

"; } $dbf->closeDBlink(); ?>