<?php include "../../root.class.php";
$html = new html();
$html->add_styles_page();
// $html->check_user_type("ADMIN");
$db = new db_safeguard();

var_dump($_POST);

$invoice_id = $_POST['invoice_id'];
$jobcard_id = $_POST['jobcard_id'];

$break_found_on = $_POST['break_found_on'];
$estimated_liters = $_POST['estimated_liters'];
$total_amount = $_POST['total_amount'];
$deposite_amount = $_POST['deposite_amount'];

$quantity = $_POST['quantity'];
$meters = $_POST['meters'];
$description = $_POST['description'];
$amount = $_POST['amount'];

//get all the individual quantity values in the array
$quantity_array = explode(",", $quantity);
$meters_array = explode(",", $meters);
$description_array = explode(",", $description);
$amount_array = explode(",", $amount);

foreach ($quantity_array as $key => $value) {
    $quantity = $quantity_array[$key];
    $meters = $meters_array[$key];
    $description = $description_array[$key];
    $amount = $amount_array[$key];

    $res = $db->insert("INSERT INTO invoice (jobcard_id, invoice_id, quantity, meters, description, amount) VALUES('$jobcard_id','$quantity','$meters','$description ','$amount')");
}

if ($res) {
    echo 1;
} else {
    echo 0;
}

