'That purchase order no longer exists.'])); } $can_order = poCanOrder($po); if (!$can_order && !in_array($po['po_status'], ['ordered', 'partial', 'received'], true)) { exit(json_encode(['error' => $po['po_status'] === 'draft' || $po['po_status'] === 'pending' ? poNumber($po) . ' needs approving before it goes to the vendor.' : poNumber($po) . ' is ' . strtolower(PO_STATUSES[$po['po_status']]['label'] ?? $po['po_status']) . '.'])); } $to = (string) ($po['vendor_contact_email'] ?: $po['vendor_email']); $from = billingEmailFrom('invoice'); ob_start(); ?>