$now
Order For: $customer_name [$lang->paidWith $paid_with]
$lang->itemOrdered |
|| $lang->unitPrice |
|| $lang->quantity |
|| $lang->extendedPrice |
";
$todaysDate=date("Y-m-d");
$subtotal=number_format($sale_total_cost-$finalTax,2,'.', '');
$final_tax=number_format($finalTax,2,'.', '');
$field_names=array('date','customer_id','sale_sub_total','sale_total_cost','paid_with','items_purchased','sold_by','comment');
$field_data=array($todaysDate,$_SESSION['current_sale_customer_id'],$subtotal,$sale_total_cost,$paid_with,$temp_total_items_purchased,$_SESSION['session_user_id'],$comment);
$dbf->insert($field_names,$field_data,$sales_table,false);
$saleID=mysql_insert_id();
$field_names=array('sale_id','item_id','quantity_purchased','item_unit_price','item_buy_price','item_tax_percent','item_total_tax','item_total_cost');
$temp_item_id='';
$temp_item_name='';
$temp_quantity_purchased=0;
$temp_item_unit_price=0;
$temp_item_buy_price=0;
$temp_item_tax_percent=0;
$temp_item_tax=0;
$temp_item_cost=0;
$item_info=array();
//Add to sales_items table
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_quantity_purchased=$item_info[3];
$temp_item_unit_price=number_format($item_info[1],2,'.', '');
$temp_item_buy_price=number_format($dbf->idToField($items_table,'buy_price',$temp_item_id),2,'.', '');
$temp_item_tax_percent=$item_info[2];
$temp_item_tax=number_format($temp_item_tax_percent/100*$temp_item_unit_price*$temp_quantity_purchased,2,'.', '');
$temp_item_cost=number_format(($temp_item_unit_price*$temp_quantity_purchased)+$temp_item_tax,2,'.', '');
$field_data=array("$saleID","$temp_item_id","$temp_quantity_purchased","$temp_item_unit_price","$temp_item_buy_price","$temp_item_tax_percent","$temp_item_tax","$temp_item_cost");
$new_quantity=$dbf->idToField($items_table,'quantity',$temp_item_id)-$temp_quantity_purchased;
$query="UPDATE $items_table SET quantity=\"$new_quantity\" WHERE $temp_item_id=id";
mysql_query($query,$dbf->conn);
$dbf->insert($field_names,$field_data,$sales_items_table,false);
$body .= "$temp_item_name |
$cfg_currency_symbol$temp_item_unit_price |
$temp_quantity_purchased |
$cfg_currency_symbol$temp_item_cost |
";
}
$body .= "
$lang->saleSubTotal: $cfg_currency_symbol$subtotal |
";
$body .= "$lang->tax: $cfg_currency_symbol$final_tax |
";
$body .= "$lang->saleTotalCost: $cfg_currency_symbol$sale_total_cost |
";
if($amt_tendered!=0)
{
$body .= "$lang->amtTendered: $cfg_currency_symbol$amt_tendered |
";
$body .= " $lang->amtChange: $cfg_currency_symbol$amt_change
|
";
}
$body .= "$lang->saleID: $saleID |
";
$sec->closeSale();
$dbf->closeDBlink();
$body .= "
$lang->contact $cfg_company:";
if($cfg_address!='')
{
$temp_address=nl2br($cfg_address);
$body .= "$lang->address: $temp_address
";
}
if($cfg_phone!='')
{
$body .= "$lang->phoneNumber: $cfg_phone
";
}
if($cfg_email!='')
{
$body .= "$lang->email: $cfg_email
";
}
if($cfg_fax!='')
{
$body .= "$lang->fax: $cfg_fax
";
}
if($cfg_website!='')
{
$body .= "$lang->website $cfg_website
";
}
if($cfg_other!='')
{
$body .= "$lang->other: $cfg_other
";
}
echo "$body";
//EMAIL RECIEPT TO MEMBER!
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($body, 70);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: mark@goodlifebikes.ca' . "\r\n";
$message = "
$message ";
echo "$headers";
// Send
mail('mark@goodlifebikes.ca', "Your Receipt from $cfg_company", $message, $headers);
?>