require_once 'filehead.php';
//include filehead file
if (isset($_SESSION['userid'])) {
    if ($_SESSION['type'] == 0) {
        require_once 'helper/Validation.php';
        //email validation
        $smarty->assign('CSS_URL', CSS_URL);
        $smarty->display('header.tpl');
        $smarty->assign('username', $_SESSION['username']);
        $smarty->display('userheader.tpl');
        if (isset($_POST['submit'])) {
            if ($_POST['vehicleid'] != NULL && $_POST['cost'] != NULL) {
                $vehicle = new buys();
                $vehicle->add(0, $_POST['vehicleid']);
                $expense = new expenses();
                if ($expense->add(2, 0, $_POST['vehicleid'], $_POST['cost'])) {
                    echo "MESSAGE : vehicle added";
                } else {
                    echo "MESSAGE : vehicle was not added";
                }
            } else {
                echo "OOPS !! You missed thing";
            }
        }
        if (isset($_POST['remove']) && isset($_POST['id'])) {
            $vehicle = new buys();
            $vehicleId = $_POST['id'];
            $allVehicles = $vehicle->get();
            $vehicle->remove($allVehicles[$vehicleId]['reg_no']);
            echo "MESSAGE: vehicle removed";
        }