Thai court greenlights government's $12bn emergency borrowing