<?php
include "db.class.php";
$db = new DBMain();

$jobcard_res = $db->exec_query('jobcards', ['*']);
$get_jobcard_number = $jobcard_res->num_rows + 1;

$jobcard_number = $get_jobcard_number;

$jobcard_date = $_POST['jobcard_date'];
$artist_name = $_POST['artist_name'];
$sculpture_name = $_POST['sculpture_name'];
$account_no = $_POST['account_no'];
$quantity = $_POST['quantity'];
$serial_nr = $_POST['serial_nr'];
$inv_nr = $_POST['inv_nr'];
$wax_paint_dep_painter_name = $_POST['wax_paint_dep_painter_name'];
$wax_paint_dep_date_in = $_POST['wax_paint_dep_date_in'];
$wax_paint_dep_date_out = $_POST['wax_paint_dep_date_out'];
$wax_work_dep_name = $_POST['wax_work_dep_name'];
$wax_work_dep_date_in = $_POST['wax_work_dep_date_in'];
$wax_work_dep_date_out = $_POST['wax_work_dep_date_out'];
$wax_work_dep_wax_kg = $_POST['wax_work_dep_wax_kg'];
$wax_runner_dep_name = $_POST['wax_runner_dep_name'];
$wax_runner_dep_date_in = $_POST['wax_runner_dep_date_in'];
$wax_runner_dep_date_out = $_POST['wax_runner_dep_date_out'];
$ceramics_dep_name = $_POST['ceramics_dep_name'];
$ceramics_dep_date_in = $_POST['ceramics_dep_date_in'];
$ceramics_dep_date_out = $_POST['ceramics_dep_date_out'];
$dewax_dep_name = $_POST['dewax_dep_name'];
$dewax_dep_date_in = $_POST['dewax_dep_date_in'];
$dewax_dep_date_out = $_POST['dewax_dep_date_out'];
$casting_dept_name = $_POST['casting_dept_name'];
$casting_dep_date_in = $_POST['casting_dep_date_in'];
$casting_dep_date_out = $_POST['casting_dep_date_out'];
$sandblast_dep_name = $_POST['sandblast_dep_name'];
$sandblast_dep_date_in = $_POST['sandblast_dep_date_in'];
$sandblast_dep_date_out = $_POST['sandblast_dep_date_out'];
$metal_dep_name = $_POST['metal_dep_name'];
$metal_dep_date_in = $_POST['metal_dep_date_in'];
$metal_dep_date_out = $_POST['metal_dep_date_out'];
$metal_dep_bronze_kg = $_POST['metal_dep_bronze_kg'];
$drill_tap = $_POST['drill_tap'];
$leveld = $_POST['leveld'];
$patina_dept_name = $_POST['patina_dept_name'];
$patina_dept_date_in = $_POST['patina_dept_date_in'];
$patina_dept_date_out = $_POST['patina_dept_date_out'];
$patina_type = $_POST['patina_type'];
$base = $_POST['base'];
$height = $_POST['height'];
$width = $_POST['width'];
$length = $_POST['length'];
$notes = $_POST['notes'];
$deadline = $_POST['deadline'];
$date_out = $_POST['date_out'];

$results = $db->insert("INSERT INTO `jobcards`(`jobcard_number`, `jobcard_date`, `artist_name`, `sculpture_name`, `account_no`, `quantity`, `serial_nr`, `inv_nr`, `wax_paint_dep_painter_name`, `wax_paint_dep_date_in`, `wax_paint_dep_date_out`, `wax_work_dep_name`, `wax_work_dep_date_in`, `wax_work_dep_date_out`, `wax_work_dep_wax_kg`, `wax_runner_dep_name`, `wax_runner_dep_date_in`, `wax_runner_dep_date_out`, `ceramics_dep_name`, `ceramics_dep_date_in`, `ceramics_dep_date_out`, `dewax_dep_name`, `dewax_dep_date_in`, `dewax_dep_date_out`, `casting_dept_name`, `casting_dep_date_in`, `casting_dep_date_out`, `sandblast_dep_name`, `sandblast_dep_date_in`, `sandblast_dep_date_out`, `metal_dep_name`, `metal_dep_date_in`, `metal_dep_date_out`, `metal_dep_bronze_kg`, `drill_tap`, `leveld`, `patina_dept_name`, `patina_dept_date_in`, `patina_dept_date_out`, `patina_type`, `base`, `height`, `width`, `length`, `notes`, `deadline`, `date_out`) VALUES ($jobcard_number ,'$jobcard_date','$artist_name','$sculpture_name','$account_no', $quantity,'$serial_nr','$inv_nr','$wax_paint_dep_painter_name','$wax_paint_dep_date_in','$wax_paint_dep_date_out','$wax_work_dep_name','$wax_work_dep_date_in','$wax_work_dep_date_out', $wax_work_dep_wax_kg,'$wax_runner_dep_name','$wax_runner_dep_date_in','$wax_runner_dep_date_out','$ceramics_dep_name','$ceramics_dep_date_in','$ceramics_dep_date_out','$dewax_dep_name','$dewax_dep_date_in','$dewax_dep_date_out','$casting_dept_name','$casting_dep_date_in','$casting_dep_date_out','$sandblast_dep_name','$sandblast_dep_date_in','$sandblast_dep_date_out','$metal_dep_name','$metal_dep_date_in','$metal_dep_date_out',$metal_dep_bronze_kg,'$drill_tap','$leveld','$patina_dept_name','$patina_dept_date_in','$patina_dept_date_out','$patina_type', $base, $height, $width, $length,'$notes','$deadline','$date_out')");

if ($results) {
    echo "<script>window.location.href='open_jobcards.php';</script>";
} else {
    echo "<script>window.location.href='new_jobcard.php';</script>";

    echo "INSERT INTO `jobcards`(`jobcard_number`, `jobcard_date`, `artist_name`, `sculpture_name`, `account_no`, `quantity`, `serial_nr`, `inv_nr`, `wax_paint_dep_painter_name`, `wax_paint_dep_date_in`, `wax_paint_dep_date_out`, `wax_work_dep_name`, `wax_work_dep_date_in`, `wax_work_dep_date_out`, `wax_work_dep_wax_kg`, `wax_runner_dep_name`, `wax_runner_dep_date_in`, `wax_runner_dep_date_out`, `ceramics_dep_name`, `ceramics_dep_date_in`, `ceramics_dep_date_out`, `dewax_dep_name`, `dewax_dep_date_in`, `dewax_dep_date_out`, `casting_dept_name`, `casting_dep_date_in`, `casting_dep_date_out`, `sandblast_dep_name`, `sandblast_dep_date_in`, `sandblast_dep_date_out`, `metal_dep_name`, `metal_dep_date_in`, `metal_dep_date_out`, `metal_dep_bronze_kg`, `drill_tap`, `leveld`, `patina_dept_name`, `patina_dept_date_in`, `patina_dept_date_out`, `patina_type`, `base`, `height`, `width`, `length`, `notes`, `deadline`, `date_out`)  VALUES ($jobcard_number ,'$jobcard_date','$artist_name','$sculpture_name','$account_no', $quantity,'$serial_nr','$inv_nr','$wax_paint_dep_painter_name','$wax_paint_dep_date_in','$wax_paint_dep_date_out','$wax_work_dep_name','$wax_work_dep_date_in','$wax_work_dep_date_out', $wax_work_dep_wax_kg,'$wax_runner_dep_name','$wax_runner_dep_date_in','$wax_runner_dep_date_out','$ceramics_dep_name','$ceramics_dep_date_in','$ceramics_dep_date_out','$dewax_dep_name','$dewax_dep_date_in','$dewax_dep_date_out','$casting_dept_name','$casting_dep_date_in','$casting_dep_date_out','$sandblast_dep_name','$sandblast_dep_date_in','$sandblast_dep_date_out','$metal_dep_name','$metal_dep_date_in','$metal_dep_date_out',$metal_dep_bronze_kg,'$drill_tap','$leveld','$patina_dept_name','$patina_dept_date_in','$patina_dept_date_out','$patina_type', $base, $height, $width, $length,'$notes','$deadline','$date_out')";
}
