<link rel="stylesheet" href="../css/sweet-alert.css" />
<?php
include("../connection.php");
include("../user.php");
// error_reporting(E_ALL);
// ini_set('display_errors', 1);

$cur_date = date('Y-m-d H:i:s');
$sys_date = date('Y-m-d');
$user = $_SESSION['user'];
$branch_id = $_SESSION['branch_id'];
if ($branch_id <> "") {
	echo $branch_id1 = $_SESSION['branch_id'];
} else {
	echo $branch_id1 = $_REQUEST['branch'];
}
$asset_id = $_REQUEST['asset_code'];
$priority = $_REQUEST['priority'];
$remarks = $_REQUEST['remarks'];
// $no_of_items = $_REQUEST['no_of_items'];
$cost = $_REQUEST['cost'];
// $location = $_REQUEST['location'];
// $department = $_REQUEST['department'];
// $division = $_REQUEST['division'];
// $fa = $_REQUEST['fa'];
$material_request_by = $_REQUEST['material_request_by'];
$Approved_By_Shift_Engineer = $_REQUEST['Approved_By_Shift_Engineer'];
$store_incharge = $_REQUEST['store_incharge'];

$item_det = mysqli_fetch_array(mysqli_query($con, "select * from asset_master where id='$asset_id'"));
// $category = $item_det['category'];
// $category_description = $item_det['category_description'];
// $quantity = $item_det['quantity'];



// $cost_update = mysqli_query($con, "update item_master set amount=quantity*value where id='$asset_id'");


// $item_dets = mysqli_fetch_array(mysqli_query($con, "select * from item_master where id='$asset_id'"));
// $quantity = $item_dets['quantity'];
// if ($quantity != 0) {
// } else {
// 	$cost_update = mysqli_query($con, "update item_master set status=1 where id='$asset_id'");
// }
$insert_repair = mysqli_query($con, "INSERT INTO scrab_master(asset_id,priority,cost,remarks,created_by,scrab_requested_by,scrab_approved_by,store_incharge)VALUES('$asset_id','$priority','$cost','$remarks','$user','$material_request_by','$Approved_By_Shift_Engineer','$store_incharge')");
if ($insert_repair) {
    $update_repair = mysqli_query($con, "update asset_master set status=3 where id='$asset_id'");
	?>
	<script>
		setTimeout(function () {
			swal({
				title: "Successfully",
				text: "completed!",
				type: "success"
			}, function () {
				window.location = "scrab.php";
			});
		}, 100);
	</script>
	<?php
} else {
	?>
	<script>
		setTimeout(function () {
			swal({
				title: "Not",
				text: "completed!",
				type: "error"
			}, function () {
				window.location = "scrab.php";
			});
		}, 100);
	</script>
	<?Php
}
?>
<script src="../js/sweet-alert.js"></script>