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

$edit_id = isset($_POST['edit_id']) ? intval($_POST['edit_id']) : 0;
$priority = $_REQUEST['priority'];
$remarks = $_REQUEST['remarks'];
$cost = $_REQUEST['cost'];
$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'"));

$update_scrap = mysqli_query($con, "UPDATE scrab_master SET 
    priority = '$priority',
    cost = '$cost',
    remarks = '$remarks',
    scrab_requested_by = '$material_request_by',
    scrab_approved_by = '$Approved_By_Shift_Engineer',
    store_incharge = '$store_incharge',
    modified_by = '$user',
    modified_on = NOW()
    WHERE id = '$edit_id'
");

if ($update_scrap) {
    ?>
    <script>
        setTimeout(function () {
            swal({
                title: "Successfully",
                text: "Updated!",
                type: "success"
            }, function () {
                window.location = "scrab.php";
            });
        }, 100);
    </script>
    <?php
} else {
    ?>
    <script>
        setTimeout(function () {
            swal({
                title: "Update Failed",
                text: "Please try again!",
                type: "error"
            }, function () {
                window.location = "scrab.php";
            });
        }, 100);
    </script>
    <?php
}
?>
<script src="../js/sweet-alert.js"></script>
