<?php

include "../../classes/autoload.php";

$order_type = str_replace(["'", "\""], "", $_POST['order_type']);

$res = $db->query("terms", "SELECT * FROM terms WHERE document_type = 'INVOICE' AND order_type = '$order_type' LIMIT 1");

if ($res->num_rows == 0) {
    echo json_encode(['notes' => '', 'terms' => '']);
} else {
    $term = $res->fetch_assoc();
    echo json_encode(['notes' => $term['notes'], 'terms' => $term['terms']]);
}