<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 <> "") {
	$branch_id1 = $_SESSION['branch_id'];
} else {
	$branch_id1 = $_REQUEST['branch'];
}

$edit_id = isset($_POST['edit_id']) ? intval($_POST['edit_id']) : 0;
$asset_id = $_POST['asset_code'];
// $division=$_REQUEST['division'];
// $department=$_REQUEST['department'];
// $location=$_REQUEST['location'];
$priority = $_REQUEST['priority'];
$remarks = $_REQUEST['remarks'];
$vendor_name = $_REQUEST['vendor_det'];
$submit_date = $_REQUEST['submit_dates'];
$expect_return_date = $_REQUEST['expect_date'];
$no_of_counts = $_REQUEST['no_of_counts'];

$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'];

$send_on = date('Y-m-d', strtotime($submit_date));
$expect_return = date('Y-m-d', strtotime($expect_return_date));

// $update_repair = mysqli_query($con, "update `asset_master` set quantity=quantity-'$no_of_counts',remark_scrap_count=remark_scrap_count+'$no_of_counts',remark_scrap_status='2' where id='$asset_id'");


$update_repair = mysqli_query($con, "
    UPDATE `repair_master` 
    SET 
        priority = '$priority',
        remarks = '$remarks',
        vendor_name = '$vendor_name',
        sendon = '$send_on',
        expect_return_date = '$expect_return',
        modify_on = NOW(),
        modify_by = '$user'
    WHERE id = '$edit_id'
");


if ($update_repair) {
    // $update_repair = mysqli_query($con, "update `asset_master` set status=2 where id='$asset_id'");
	?>
	<script>
		setTimeout(function () {
			swal({
				title: "Successfully",
				text: "Updated Successfully!",
				type: "success"
			}, function () {
				window.location = "repair.php";
			});
		}, 100);
	</script>
	<?php
} else {
	?>
	<script>
		setTimeout(function () {
			swal({
				title: "Not",
				text: "completed!",
				type: "error"
			}, function () {
				window.location = "repair.php";
			});
		}, 100);
	</script>
	<?php
}
?>
<script src="../js/sweet-alert.js"></script>
