require_once '../lib/trucks.php';
require_once '../lib/PeopleAssignments.php';
mysql_select_db($db_name, $oConn);
// 2014-09-16 Created ^CS
if ($_POST['save'] != "") {
    $Identifier = $_POST['ID'];
    $truckdetails = Trucks::Retrieve($Identifier, $_SESSION['customerId']);
    $truck = new Trucks();
    $truck->ID = $_POST['ID'];
    $truck->TruckName = $truckdetails->TruckName;
    $truck->TruckID = $truckdetails->TruckID;
    $truck->TruckSerial = $truckdetails->TruckSerial;
    $truck->TruckPart = $truckdetails->TruckPart;
    $truck->TruckDriver = $_POST['TruckDriver'];
    $truck->CustomerId = $_SESSION['customerId'];
    $truck->Update();
    header("Location: maps_trucks.php#Truck");
    exit;
}
$ID = $_GET['ID'];
$truck = Trucks::Retrieve($ID, $_SESSION['customerId']);
$driving = $truck->TruckDriver;
?>

<form action="maps_editdriver.php" method="POST" enctype="application/x-www-form-urlencoded" id="edit_driver">
	<p>
		<label class="formstyle">Select New Driver : </label>
		<select class="validate" id="TruckDriver" name="TruckDriver">
			<option value='0'>Select...</option>
			<?php 
$drivers = PeopleAssignments::GetAssignableGPS($_SESSION['customerId']);
    }
    $truck = new Trucks();
    $truck->ID = $_POST['ID'];
    $truck->TruckName = $_POST['TruckName'];
    $truck->TruckSerial = $_POST['Serial'];
    $truck->TruckPart = $_POST['Part'];
    $truck->TruckDriver = $_POST['Driver'];
    $truck->TruckID = $_POST['TruckID'];
    $truck->CustomerId = $_SESSION['customerId'];
    if ($truck->ID == '') {
        $truck->Insert();
        if ($truck->ID == -1) {
            $error = ERR_BAD_INSERT;
        }
    } else {
        if (!$truck->Update()) {
            $error = ERR_BAD_UPDATE;
        }
    }
    if ($error == 0) {
        header("Location: maps_trucks.php#Truck");
        exit;
    }
}
if ($mode == "edit") {
    $truck = Trucks::Retrieve($ID, $_SESSION['customerId']);
    if ($truck === false) {
        $error = ERR_BAD_RETRIEVE;
        $truck = new Trucks();
        //blank
    } else {