<?php

include "../../root.class.php";
$db = new db_safeguard();


$stock_id = $db->query("stock", "INSERT INTO stock (`category_id`,`description`,`stock_type`) VALUES ('{$_POST['category_id']}','{$_POST['description']}','{$_POST['stock_type']}')");

// add stock item to stock take stock
$db->query("stock_take_stock", "INSERT INTO stock_take_stock (`item_id`,`stock_take_id`,`amount_in_stock`,`amount_counted`) VALUES ('{$stock_id}',{$_GET['stock_take_id']},0,{$_POST['qty']})");

echo "<script>location.href='stock_take.php?record_id={$_GET['stock_take_id']}';</script>";