<?php
// Database connection
$conn = new mysqli("localhost", "transpa2_uplinepj", "Police2345@1", "transpa2_jetinstantTQ");

    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } ?>

<?php

if (isset($_POST['update_major'])) {
        
    // Get values from form
    $partition = $_POST['poe']; // Labourer_price
    $val1 = $_POST['length'];           // SomeLabourers_1c
    $val2 = $_POST['course'];           // SomeLabourers_1B
    $val3 = $_POST['height'];           // SomeLabourers_1D
    $basket = $_POST['be'];
    $maintainer = $_POST['empp'];
    $concrete = $_POST['aboc'];
    $mason = $_POST['ampd'];

    // Update Partition of Excavation
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$partition', SomeLabourers_1c='$val1', SomeLabourers_1B='$val2', SomeLabourers_1D='$val3' WHERE labour_name='Partition of Excavation'");

    // Update other labour prices
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$basket' WHERE labour_name='Basket Excavation'");
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$maintainer' WHERE labour_name='Excavation maintener per person'");
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$concrete' WHERE labour_name='Bag of Concrete'");
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$mason' WHERE labour_name='Mason per day'");

    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("Major Control update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}
?>
<!--Major control ends-->

<?php

if (isset($_POST['block_work'])) {
        
    // Get values from form
    $block9hldwn = $_POST['somelabourer_1C']; $block9hlup = $_POST['somelabourer_1D']; // Labourer_price
    $block6hldwn = $_POST['somelabourer_1C'];   $block6hlup = $_POST['somelabourer_1D'];        // SomeLabourers_1c
    $block6sldwn = $_POST['somelabourer_1C'];    $block6slup = $_POST['somelabourer_1D'];       // SomeLabourers_1B
    $block5sldwn = $_POST['somelabourer_1C'];    $block5slup = $_POST['somelabourer_1D'];         // SomeLabourers_1D
    $block4hldwn = $_POST['somelabourer_1C'];    $block4hlup = $_POST['somelabourer_1D'];
    
    // Update block work
    $conn->query("UPDATE upline_app_blocksettings SET Down_Labours='$block9hldwn', Up_Labours='$block9hlup' WHERE Block_name='9 inches Hollow Block' ");

    // Update other labour prices
    $conn->query("UPDATE upline_app_blocksettings SET Down_Labours='$block6hldwn', Up_Labours='$block6hlup' WHERE Block_name='6 inches Hollow Block'");
    $conn->query("UPDATE upline_app_blocksettings SET Down_Labours='$block6sldwn', Up_Labours='$block6slup' WHERE Block_name='6 inches Solid Block'");
    $conn->query("UPDATE upline_app_blocksettings SET Down_Labours='$block5sldwn', Up_Labours='$block5slup' WHERE Block_name='5 inches Solid Block'");
    $conn->query("UPDATE upline_app_blocksettings SET Down_Labours='$block4hldwn', Up_Labours='$block4hlup' WHERE Block_name='4 inches Hollow Block'");

    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("BLock work update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}


?>
<!--Block work ends-->

<?php
if (isset($_POST['sand_fill'])) {
        
    // Get values from form
    $partition1 = $_POST['A_37']; // Labourer_price
    $val2 = $_POST['A_38'];           // SomeLabourers_1c 
    
    // Update other labour prices
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$partition1' WHERE labour_name='10 Tyers Truck'");
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$val2' WHERE labour_name='2 in 1 Truck'");
   
    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("Sand filling update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}



?>
<!--sand filling ends--> 
<?php
if (isset($_POST['foundation_updt'])) {
        
    // Get values from form
    $partition1 = $_POST['A_38']; // Labourer_price
                   
    // Update other labour prices
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$partition1' WHERE labour_name='foundation partition of Exterior walls' ");
    
    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("Foundation update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}

?>

<!--foudation ends here-->  

<?php
if (isset($_POST['mainbui'])) {
        
    // Get values from form
    $labourer_price_ext = $_POST['prize'];  $length_ext = $_POST['length']; // Exterior
	$labourer_price_int = $_POST['prize'];  $length_int = $_POST['length']; // interior
	
                   
    // Update other labour prices
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$labourer_price_ext', SomeLabourers_1B='$length_ext'  WHERE labour_name='main building partition of exterior walls' ");
	$conn->query("UPDATE upline_app_laboursettings SET labourer_price='$labourer_price_int', SomeLabourers_1B='$length_int' WHERE labour_name='foundation partition of Exterior walls' ");
    
    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("Main building update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}

?>
<!--main building end-->
<?php
if (isset($_POST['decking'])) {
        
    // Get values from form
	$price =$_POST['prize'];
    $partition1 = $_POST['area']; // Labourer_price
                   
    // Update other labour prices
    $conn->query("UPDATE upline_app_laboursettings SET labourer_price='$price', labourer_job_area='$partition1' WHERE labour_name='Decking (sq m)' ");
    
    /*echo "Update successful!";*/ echo '<script language ="javascript" type= "text/javascript"> alert("Decking update is sucessfull"); location.href="labourer.php";</script>';
    $conn->close();
}

?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
</body>
</html>