<?php
include('../include/session.php');



date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$quote_no = $_GET['quote_no'];
$truss_item = $_GET['category'];
$store_item_id = $_GET['store_item_id_select'];
$qty = $_GET['qty_text'];

$table_name = $_SESSION['db_prefix']."_store_items";
$price_query = "SELECT purchase_price, price FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
$price_result = mySQL_query($price_query);
$price = mysql_result($price_result, 0, "price");
$purchase_price = mysql_result($price_result, 0, "purchase_price");

$table_name = $_SESSION['db_prefix']."_quotation_lines";
$add_query = "INSERT INTO $table_name (quote_no, store_item_id, truss_item, quantity, price, purchase_price) VALUES ('".$quote_no."', '".$store_item_id."', '".$truss_item."', '".$qty."', '".$price."', '".$purchase_price."' ) ";
execsql($add_query);

$table_name = $_SESSION['db_prefix']."_tracking_sales";
$trackingQuery = "INSERT INTO $table_name (entry_date, user, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '50', '".$quote_no."' , '".$store_item_id."','','".$qty."' )";
execsql($trackingQuery);


?>


<script language="javascript" type="text/javascript">
         window.location="../sales/quotation_edit.php?quote_no=<?php echo $quote_no ?>&authorise=0";
</script>